let keyword = "";
let title = "";
let sku = "";
let shop_name = "";
let acc_email = "";
let acc_pass = "";
let login_rg = "";
let imgname = "";
let deviceId = device.getDeviceId()
let lname = "";
let fname = "";
let lname_kana = "";
let fname_kana = "";
let post = "";
let address = "";
let iphone_1 = "";
let iphone_2 = "";
let iphone_3 = "";

let login_rgaa = "";
let ip_ip = "";
let imagesname = "";
let jd = 0.6;
let y = 0;
let acc_order = "";
let acc_id = "";
let acc_year = "";
let acc_yue = "";
let acc_day = "";
let acc_sex = "";
let acc_email_fuzhu = "";
let acc_iphone_all = "";
let acc_iphone_static = "";
let acc_iphone_id = "";
let acc_iphone_yzm = "";
let pay_select = "";
let delstatus = false
let click_keyword = "";

main()


function main() {
    laoleng.EC.init()
    //使用精确模式,识别中文需要此用法,其他用法参考文档
    laoleng.EC.initOcr({"level": "accurate"})
    laoleng.EC.initNode()
    while (true) {
        //     for (let i = 0; i < 1; i++) {

        login_rgaa = getdate_login_rg();
        logd(login_rgaa + " ------------" + login_rgaa);

        // 删除仍为时间命名的邮箱记录
        if (login_rgaa.includes("delete")) {
            // 当 login_rgaa 包含 "delete" 时执行的代码
            console.log("包含delete");
            deleteold(login_rgaa)
            if (delstatus) {
                break
            }
        } else {
            // 当 login_rgaa 不包含 "delete" 时执行的代码
            console.log("不包含delete");
        }
        // return false
        if (login_rgaa == "rakuten_view") {
            logd(acc_email + " rakuten_view开始------------");
            rakuten_view()
        }

        // return false
        if (login_rgaa == "rakuten_pay") {
            logd(acc_email + " rakuten_pay开始------------");
            rakuten_pay()
        }

        if (login_rgaa == "rakuten_login") {
            //登录订购
            var acc_date = timeFormat("HH")
            if (acc_date == "01" || acc_date == "02" || acc_date == "03" || acc_date == "04" || acc_date == "05" || acc_date == "06" || acc_date == "07" || acc_date == "08") {
                logd(acc_date + " 注册开始凌晨------------");
                rakuten_register()
                // if (!rakuten_register()) {
                //     continue
                // }
            } else {

                logd(acc_email + " rakuten_login开始------------");
                rakuten_login()
            }
        }

        if (login_rgaa == "rakuten_register") {
            //按照设置是否注册还是 订单店铺订单
            logd(acc_email + " rakuten_register开始------------");
            rakuten_register()
        }

        if (login_rgaa == "gmail_register") {
            //按照设置是否注册还是 订单店铺订单
            logd(acc_email + " gmail_register开始------------");
            gmail_register()
        }

        if (login_rgaa == "qoo10_register") {
            logd(acc_email + " qoo10_register开始------------");
            qoo10_register()
        }

        //
        // //ins注册
        // if (login_rgaa == "ins_register") {
        //     //按照设置是否注册还是 订单店铺订单
        //     logd(acc_email + " ins_register开始------------");
        //     ins_register()
        // }
        //
        // //ins发布
        // if (login_rgaa == "ins_publish") {
        //     //按照设置是否注册还是 订单店铺订单
        //     logd(acc_email + " ins_publish开始------------");
        //     ins_publish()
        // }
        //
        // //youtable 注册
        // if (login_rgaa == "youtable_register") {
        //     //按照设置是否注册还是 订单店铺订单
        //     logd(acc_email + " youtable_register开始------------");
        //     youtable_register()
        // }
        // //youtable 发布
        // if (login_rgaa == "youtable_publish") {
        //     //按照设置是否注册还是 订单店铺订单
        //     logd(acc_email + " youtable_publish开始------------");
        //     youtable_publish()
        // }
        //
        // //lm8_register 发布
        // if (login_rgaa == "lm8_register") {
        //     //按照设置是否注册还是 订单店铺订单
        //     logd(acc_email + " lm8_register开始------------");
        //     lm8_register()
        // }
        //
        // //lm8_publish 发布
        // if (login_rgaa == "lm8_publish") {
        //     //按照设置是否注册还是 订单店铺订单
        //     logd(acc_email + " lm8_publish开始------------");
        //     lm8_publish()
        // }
        //
        // //tk_register
        // if (login_rgaa == "tk_register") {
        //     //按照设置是否注册还是 订单店铺订单
        //     logd(acc_email + " tk_register开始------------");
        //     tk_register()
        // }
        //
        // //tk_publish
        // if (login_rgaa == "tk_publish") {
        //     //按照设置是否注册还是 订单店铺订单
        //     logd(acc_email + " tk_publish开始------------");
        //     tk_publish()
        // }
        //
        // //x_register
        // if (login_rgaa == "x_register") {
        //     //按照设置是否注册还是 订单店铺订单
        //     logd(acc_email + " x_register开始------------");
        //     x_register()
        // }
        //
        // //x_publish
        // if (login_rgaa == "x_publish") {
        //     //按照设置是否注册还是 订单店铺订单
        //     logd(acc_email + " x_publish开始------------");
        //     x_publish()
        // }
        //
        // //amazon_register
        // if (login_rgaa == "amazon_register") {
        //     //按照设置是否注册还是 订单店铺订单
        //     logd(acc_email + " amazon_register开始------------");
        //     amazon_register()
        // }
        //
        // //root_register
        // if (login_rgaa == "root_register") {
        //     //按照设置是否注册还是 订单店铺订单
        //     logd(acc_email + " root_register开始------------");
        //     root_register()
        // }
        //
        // //root_publish
        // if (login_rgaa == "root_publish") {
        //     //按照设置是否注册还是 订单店铺订单
        //     logd(acc_email + " root_publish开始------------");
        //     root_publish()
        // }
    }
}

//删除操作
function deleteold(del) {
    // 后面优化可能使用 使用字符串包含操作进行模糊匹配
    let parts = []
    if (del.startsWith("delete_") && del.length >= 10) {
        // 获取delete_之后的字符串
        let datePart = del.slice(7);
        // 拆分年月成一个数组 [2024,12]
        parts = datePart.split('-');
        if (parts.length === 2 && parts[0].length === 4 && parts[1].length === 2 && !isNaN(Number(parts[0])) && !isNaN(Number(parts[1]))) {
            logd(parts);
        } else {
            console.log(`${del} 不匹配字符串`);
        }
    }
    // 使用正则表达式进行模糊匹配
    let pattern = /^delete_\d{4}-\d{2}$/
    if (pattern.test(del)) {
        logd(`符合删除规则 ${del}`);
        // deleterecord(parts)
        clickdel(parts)
    } else {
        console.log(`${del} 不符合删除匹配规则`);
    }
}

//一件新机器
function new_iphone() {
    logd("---------一件新机开始----------");
    var result = appLaunch("com.superdev.AMG", "1");
    logd("打开AMG: " + result);
    if (!result) {
        console.log('打开AMG失败,再次打开')
        home()
        sleep(500)
        click_keyword = "AMG";
        click_wenzi()
        sleep(5000)
    }
    sleep(8000);
    var new_iphone = text_pd("AMG");
    if (new_iphone == null) {
        logd("找不到打开在等待10秒");
        sleep(8000);
    }

    //一件新机
    var url = "http://127.0.0.1:8080/cmd";
    var pa = {"fun": "newRecord"};
    var x = http.httpGet(url, pa, 13 * 1000, {"User-Agent": "iPhone"});
    sleep(18000);
    // if (login_rgaa.includes("2") == true) {
    if (x.includes("2") === true) {
        logd("一件新机器 成功" + x);
    } else {
        sleep(2000);
        var url = "http://127.0.0.1:8080/cmd";
        var pa = {"fun": "newRecord"};
        var x = http.httpGet(url, pa, 13 * 1000, {"User-Agent": "iPhone"});
        sleep(18000);
    }


//还原指定记录
// var url = "http://127.0.0.1:8080/cmd?fun=setRecord";
// var pa = {"recordName": "aaa"};
// var x = http.httpGet(url, pa, 10 * 1000, {"User-Agent": "iPhone"});
}

// 通过app包打开app的方法
function openApp(jp) {
    var result = appLaunch(jp, '1');
}

//打开App的方法
function open_rakuten() {
    var result = appLaunch("jp.co.rakuten.ichiba", "1");
    logd("打开乐天app 等待5秒");
    sleep(3000);

    //今はしない
    click_tanchuan()
    logd("点击首页今はしない");
    sleep(700);
    click_tanchuan()
    logd("点击首页今はしない");
    sleep(700);

    //  点击广告的 x
    closed()
    sleep(2000)
    closed()
}

//关闭App的方法
function closeapp(appname) {
    logd("current deviceId : " + deviceId)

    let stopApp = tjCenter.stopApp(deviceId, appname)
    if (stopApp == null || stopApp == "") {
        logd("stopApp  成功")
    } else {
        logd("stopApp  失败: " + stopApp)
        return
    }

    // var result = appLaunch(appname, "1");
    // sleep(500);
    // if (result) {
    //     var result = home();
    //     if (result) {
    //         sleep(500);
    //         var result = clickPoint(680, 60);
    //         if (result) {
    //             sleep(500);
    //             var result = clickPoint(538, 332);
    //             if (result) {
    //                 sleep(500);
    //                 var result = clickPoint(474, 586);
    //                 if (result) {
    //                     sleep(500);
    //                     var result = clickPoint(196, 224);
    //                     if (result) {
    //                         sleep(500);
    //                         huadong()
    //                         sleep(500);
    //                         home();
    //                         sleep(500);
    //                     }
    //                 }
    //             }
    //         } else {
    //             logd("点击失败");
    //         }
    //     } else {
    //         logd("失败");
    //     }
    // }


}

//删除指定记录名
function deleterecord(parts) {
    var result = appLaunch("com.superdev.AMG", "1");
    logd("打开AMG: " + result);
    if (!result) {
        console.log('打开AMG失败,再次打开')
        home()
        sleep(500)
        var againresult = appLaunch("com.superdev.AMG", "1");
    }
    sleep(6000);
    var new_iphone = text_pd("一键新机");
    if (new_iphone == null) {
        logd("找不到打开在等待10秒");
        sleep(7000);
    }
    //获取当前记录名
    var url = "http://127.0.0.1:8080/cmd";
    var pa = {"fun": "getCurrentRecordName"};
    var old_name = http.httpGet(url, pa, 10 * 1000, {"User-Agent": "iPhone"});
    logd("旧名称: " + old_name);
    sleep(1000);

    // 判断当前名字是否包含专属词
    let inside = false
    let oldname = old_name.split('-')
    for (let i = 0; i < parts.length; i++) {
        if (oldname.indexOf(parts[i]) !== -1) {
            inside = true
        }
    }
    //符合就跳到下一条记录名再删除上一条记录名
    if (inside) {
        // 下一条记录名
        nextrecord()
        sleep(6000)
        // 删除上一条记录名
        var delurl = "http://127.0.0.1:8080/cmd?fun=deleteRecord&recordName=" + old_name
        var deletename = http.httpGet(delurl, "", 10 * 1000, {"User-Agent": "iPhone"});
        if (deletename == '0') {
            console.log('删除失败')
        } else if (deletename == '1') {
            logd(acc_email + "未命名: " + deletename + "已删除");
        } else if (deletename == '2') {
            console.log('正在删除')
        }
        sleep(2000)
        home()
    } else {
        console.log('可能已经没有未命名的')
    }
}

// 点击删除
function clickdel(parts) {
    var result = appLaunch("com.superdev.AMG", "1");
    logd("打开AMG: " + result);
    if (!result) {
        console.log('打开AMG失败,再次打开')
        home()
        sleep(500)
        var againresult = appLaunch("com.superdev.AMG", "1");
    }
    sleep(3000);
    var new_iphone = text_pd("一键新机");
    if (new_iphone == null) {
        logd("找不到打开在等待10秒");
        sleep(7000);
    }
    laoleng.EC.initNode()
    findNode(label("备份记录").type("StaticText"), true)
    sleep(500)
    huadong()
    sleep(500)
    huadong()
    sleep(500)
    huadong()
    sleep(1500)
    // 先释放老的数据
    releaseNode();

    while (true) {
        laoleng.EC.initNode()
        if (findNode(label("编辑").type("Button"), true)) {
            sleep(1000)
            if (findNodeAll(labelMatch("2025.*").type("StaticText").accessible(true))) {
                console.log(gNodeAll.length)
                for (let i = 0; i < gNodeAll.length; i++) {
                    logd(JSON.stringify(gNodeAll[i]))
                    if (gNodeAll[i].child)
                        //点击
                        gNodeAll[i].clickCenter()
                    sleep(500)
                }
                findNode(label("删除").type("Button"), true)
            } else {
                console.log('meiyou')
                delstatus = true
                break
            }
            // return false
            // if (findNodeAll(type("Cell").depth(8).visible(true))) {
            //     for (let i = 0; i < gNodeAll.length; i++) {
            //         logd(JSON.stringify(gNodeAll[i]))
            //         if (gNodeAll[i].child)
            //             //点击
            //             gNodeAll[i].clickCenter()
            //         sleep(500)
            //     }
            //     findNode(label("删除").type("Button"), true)
            // }
        } else {
            console.log('没有找到编辑按键')
        }
    }
}

// 下一条
function nextrecord() {
    var nexturl = "http://127.0.0.1:8080/cmd";
    var pa = {"fun": "nextRecord"};
    var nextrecord = http.httpGet(nexturl, pa, 10 * 1000, {"User-Agent": "iPhone"});
    logd("下一条: " + nextrecord);
    sleep(1000);
}

//新机器改名字
function new_iphone_new_name() {
    var result = appLaunch("com.superdev.AMG", "1");
    logd("打开AMG: " + result);
    if (!result) {
        console.log('打开AMG失败,再次打开')
        home()
        sleep(500)
        var againresult = appLaunch("com.superdev.AMG", "1");
    }
    sleep(6000);
    var new_iphone = text_pd("一键新机");
    if (new_iphone == null) {
        logd("找不到打开在等待10秒");
        sleep(7000);
    }

    //获取当前记录名
    var url = "http://127.0.0.1:8080/cmd";
    var pa = {"fun": "getCurrentRecordName"};
    var old_name = http.httpGet(url, pa, 10 * 1000, {"User-Agent": "iPhone"});
    logd("旧名称: " + old_name);
    sleep(1000);
    //重命名指定记录
    var url = "http://127.0.0.1:8080/cmd?fun=setRecordName&oldName=" + old_name + "&newName=" + acc_email;
    var newname = http.httpGet(url, "", 10 * 1000, {"User-Agent": "iPhone"});
    logd("新名称: " + newname + " : " + acc_email);
    sleep(1000);
    logd("---------一件新机改名字完成----------");
//还原指定记录
// var url = "http://127.0.0.1:8080/cmd?fun=setRecord";
// var pa = {"recordName": "aaa"};
// var x = http.httpGet(url, pa, 10 * 1000, {"User-Agent": "iPhone"});
}

//---------------------注流方法-----------------------------------------------------------

// 搜索
function viewSearch() {
    laoleng.EC.initNode()
    sleep(500)
    if (findNode(name("キーワード検索").label("キーワード検索").type("SearchField"), true)) {
        logd("搜索产品点到产品页面")
        sleep(1000);
        //2.输入关键词
        input_keyword(keyword);
        logd("输入关键词: " + keyword);
        //回车
        an_enter();
        sleep(2000);

        //点击店铺名称
        logd(shop_name)
        autoswiper(40)

    } else {
        logd("未点击搜索框");
    }
}

// 滑动15s
function scrollview(howlong) {
    for (let i = 0; i < howlong; i++) {
        swipeToPoint(400, 600, 400, 300, 300);
        sleep(random(1200, 2000))
    }

    for (let j = 0; j < Math.floor(howlong / 2); j++) {
        swipeToPoint(400, 400, 400, 600, 300);
        sleep(random(1200, 2000))
    }
}

//回传访问ip
function callbackIp() {
    //获取当前ip
    var nowIP = laoleng.http.getNetIp();
    logd(nowIP);
    var url = "https://rakuten.erp2018.top/rankingsRealtime_view.php?ip=" + nowIP + "&cpsku=" + sku;
    var x = http.httpGet(url, "", 90 * 1000, {"User-Agent": "iphone"});
    logd("回传 ip: " + acc_email + " 错误信息：" + x);
}

//---------------------注流方法结束-----------------------------------------------------------


//登录支付rakuten_pay
function rakuten_pay() {
    //登录订购RPP订单
    rakuten_pay_getdate();
    sleep(200);
    if (acc_email != "" && acc_pass != "" && keyword != "" && shop_name != "") {
        logd("------资料正常开始注册Pay------");

        //一键新机
        new_iphone()

        //打开乐天app
        open_rakuten()

        //仅登录账户
        if (rakuten_login_acc()) {
            return false
        }

        // 判断登录成功 判断购物车是否有商品 搜索产品点到产品页面
        click_search_cp()

        //产品页面 点击属性
        click_cp_attribute()

        //判断是否在购物车页面
        cart_page()//判断是否在购物车页面

        //再次输入密码验证或者再次登录
        login_rg_page()

        //判断//选支付方式
        rakuten_pay_add_payment()

        //判断//选支付确认页面
        rakuten_pay_add_payment_conf()

        //判断//获取订单号
        success_order()
        // return false
        //关闭乐天app
        sleep(500)
        closeapp("jp.co.rakuten.ichiba")
        sleep(100)

    } else {
        logd("-------资料问题-------");
    }
}

//---------增加访客流量------------------------------------------------------------
function rakuten_view() {
    getdate();
    sleep(200);
    if (acc_email != "" && keyword != "" && shop_name != "" && acc_email != "" && acc_pass != "" && acc_pass != "undefined") {
        logd("------资料正常开始注流------");

        //一键新机
        new_iphone()

        //打开乐天app
        open_rakuten()

        // 搜索本店商品并点击
        viewSearch()

        // 滑动
        scrollview(random(1, 5))

        //回传Ip
        callbackIp()

    }
}

//---------成功订单 增加访客流量------------------------------------------------------------
function rakuten_key_view() {
    logd("------开始获取今天成功订单的关键词------");
    rakuten_getdate_day_keyword_view();

    sleep(200);
    if (keyword != "") {
        logd("------成功获取今天成功订单关键词------");
        //点击首页
        click_keyword = "ai.home";
        click_wenzi()
        sleep(2000);
        // 搜索本店商品并点击
        viewSearch()

        // 滑动
        scrollview(random(1, 5))

        //回传Ip
        callbackIp()

    }
}

//---------增加访客结束------------------------------------------------------------

//---------登录Login------------------------------------------------------------
function rakuten_login() {
//登录订购RPP订单
    getdate();
    sleep(200);
    if (acc_email != "" && keyword != "" && shop_name != "" && acc_email != "" && acc_pass != "" && acc_pass != "undefined") {
        logd("------资料正常开始注册------");

        //一键新机
        new_iphone()

        //打开乐天app
        open_rakuten()

        //仅登录账户
        if (rakuten_login_acc()) {
            return false
        }

        // 判断登录成功 判断购物车是否有商品 搜索产品点到产品页面
        click_search_cp()

        //产品页面 点击属性
        click_cp_attribute()

        //判断是否在购物车页面
        cart_page()//判断是否在购物车页面

        //再次输入密码验证或者再次登录
        login_rg_page()

        //判断//选支付方式
        add_payment()

        //判断//选支付确认页面
        add_payment_conf()

        //判断//获取订单号
        success_order()
        // return false
        //关闭乐天app
        sleep(500)
        closeapp("jp.co.rakuten.ichiba")
        sleep(100)

    } else {
        logd("-------资料问题-------");
    }


}

//---------登录Login结束------------------------------------------------------------
//获取数据
function getdate() {
    var url = "https://rakuten.erp2018.top/rankingsRealtime_login_a_1.php";
    //var pa = {"type": "顺序one"};
    var x = http.httpGet(url, "", 40 * 1000, {"User-Agent": "test"}
        )
    ;
    let arr = x.split("|");
    keyword = arr[0];
    title = arr[1];
    sku = arr[2];
    shop_name = arr[3];
    acc_email = arr[4];
    acc_pass = arr[5];
    logd(keyword + "|" + title + "|" + sku + "|" + shop_name + "|" + acc_email + "|" + acc_pass);
}

//get 提交不能有中文，不能有空格
//login 支付
function rakuten_pay_getdate() {
    sleep(1000)
    var url = "https://rakuten.erp2018.top/rankingsRealtime_pay_api.php"
    var x = http.httpGet(url, "", 40 * 1000, {"User-Agent": "test"}
        )
    ;
    let arr = x.split("|");
    //1|pedrijudygarcia@gmail.com|m9F1eZsLhy|立体パズル|ブルーホエール|渡部|勝夫|ワタナベ|カツオ| バンベール春日井904|4860833|080-6910-3232
    acc_id = arr[0];
    acc_email = arr[1];
    acc_pass = arr[2];
    keyword = arr[3];
    shop_name = arr[4];
    lname = arr[5];
    fname = arr[6];
    lname_kana = arr[7];
    fname_kana = arr[8];
    address = arr[9];
    post = arr[10];
    iphone_1 = arr[11];
    iphone_2 = arr[12];
    iphone_3 = arr[13];
    pay_select = arr[14];

    logd(keyword + "|" + acc_email + "|" + acc_pass + "|" + pay_select);


}

//get 提交不能有中文，不能有空格
//login订单回传 邮箱+设备id
function updateemail_static() {
    var ip_ip_v4 = get_ip();
    sleep(1000)
    var url = "https://rakuten.erp2018.top/rankingsRealtime_login_sub.php?type=Remarks-Email-success&account_email=" + acc_email + "&device_id=" + deviceId + "&orderid=" + acc_order + "_" + timeFormat("yyyy-MM-dd-HH:mm:ss") + "&ip=" + ip_ip_v4;
    var x = http.httpGet(url, "", 90 * 1000, {"User-Agent": "iphone"});
    logd("回传 备注邮箱使用成功: " + acc_email + " 错误信息：" + x);
}

//get 提交不能有中文，不能有空格
//注册回传注册状态和设备id
function rg_updateemail_static() {
    var ip_ip_v4 = laoleng.http.getNetIp();

    var url = "https://gz2.erp2018.top/wjorder/api/mobile/select2_json_sub.php?type=email_success&orderid=" + acc_order + "_" + timeFormat("yyyy-MM-dd-HH:mm:ss") + "&email=" + acc_email + "&id=" + acc_id + "&device_id=" + deviceId + "&ip=" + ip_ip_v4;
    //var url = "https://gz2.erp2018.top/wjorder/api/mobile/select2_json_sub.php?type=email_success&orderid=402248-20230217-0067746918_2025-01-02_21:21:57&email=znvsasdhjgsaabdzzvxnzbxs@gmail.com&id=328081&device_id=00008030-001111963A23802E&ip=106.128.34.51"
    var x = http.httpGet(url, "", 90 * 1000, {"User-Agent": "iphone"});
    logd("回传 备注邮箱使用成功: " + acc_email + " ID: " + acc_id + " 错误信息：" + x);
    logd(url);
}

//回传 账户无法登录
function update_login_fail() {
    var url = "https://rakuten.erp2018.top/rankingsRealtime_login_sub.php?account_no=Account-Login-Fail&account_email=" + acc_email;
    // var pa = {"account_email": acc_email};
    var x = http.httpGet(url, "", 90 * 1000, {"User-Agent": "iphone"});
    logd("回传 账户无法登录操作: " + acc_email + " 错误信息：" + x);
}

//回传 还原库存
function updateinventory(acc_order) {
    var url = "https://rakuten.erp2018.top/reduction_rakuten.php";
    var pa = {"orderid": acc_order};
    var x = http.httpGet(url, pa, 80 * 1000, {"User-Agent": "iphone"});
    logd("回传 还原库存: " + x);
}

function get_ip() {
    var str_html = http.httpGet("https://api.ip.sb/geoip", "", 30 * 1000, {"User-Agent": "iphone"});
    var str_html_json = JSON.parse(str_html);

    return str_html_json.ip;
}

//回传订单信息
function updateorderid(orderid, strsku) {
    var ip_ip_v4 = get_ip();
    sleep(1000)
    var orderid_keyword = utils.base64Encode(orderid + "[" + keyword + "]")
    var url = "https://rakuten.erp2018.top/rankingsRealtime_api.php?orderid=" + orderid_keyword + "&sku=" + strsku + "&ip_ip=" + ip_ip_v4;
    var x = http.httpGet(url, "", 90 * 1000, {"User-Agent": "iphone"});
    logd("回传 订单信息: " + orderid + x);
    logd(url);
}

//  自己插入的方法---------------------------------------------------------------------

//等待延迟
/**
 * @param {S} selector 选择器
 * @param {Boolean?} isClick 是否点击
 * @param {Number} time 每次循环的等待时长
 * @param {Number} maxwait 最大循环次数
 * @return {Boolean} true/false;
 * @example
 * utfind(label("aaa").id("bbb"),1000,true,5)
 */
function utfind(selector, time, isClick = false, maxwait) {
    laoleng.EC.initNode()
    let count = 0
    while (true) {
        if (findNode(selector)) {
            if (g_ret) {
                if (isClick) {
                    g_ret.clickCenter()
                    sleep(random(500, 1000))
                }
                return true
            }
            break
        } else {
            sleep(time)
            count++
        }
        if (count > maxwait) {
            console.log('等待达到最大次数')
            break
        }
    }
}

//生成4位随机数  电话
function get4random() {
    let result = '';
    for (let i = 0; i < 4; i++) {
        // 生成 0 到 9 的随机数字
        let digit = random(0, 9);
        result += digit;
    }
    return result;
}

// 输入框左边的距离
function boundLeftX() {
    return random(50, 80)
}

//坐标Y轴的中心点
function boundCenterY(bounds) {
    // if (!bounds || bounds.top === undefined || bounds.bottom === undefined) {
    //     return 0 // 或者返回 null
    // }
    // return bounds.top + (bounds.bottom - bounds.top) / 2
    const centerY = bounds?.top + (bounds?.bottom - bounds?.top) / 2
    return centerY ?? 0 // 如果 centerY 是 undefined，则返回 0
}

//点击
function cleft(bounds) {
    return clickPoint(boundLeftX(), boundCenterY(bounds))
}


//随机生成一个小写字母
function getlowletter() {
    // 生成一个 0 到 25 的随机整数，对应于小写字母 a 到 z 的范围
    let randomIndex = Math.floor(Math.random() * 26);
    // 将随机整数转换为小写字母的 ASCII 码（a 的 ASCII 码是 97）
    let randomCharCode = 97 + randomIndex;
    // 将 ASCII 码转换为字符
    let randomLetter = String.fromCharCode(randomCharCode);
    return randomLetter;
}

//随机选择
function randChoose() {
    logd('进入选择')
    var rod = random(1, 3)
    logd(rod + '随机')
    if (rod == 1) {
        let op1 = findNode(name("充電ケーブル 3in1").type("StaticText"), true)
        logd(1)
        sleep(500)
    }
    if (rod == 2) {
        let op2 = findNode(name("当店で使える10%クーポン").type("StaticText"), true)
        logd(2)
        sleep(500)
    }
    if (rod == 3) {
        let op3 = findNode(name("当店で使える10%クーポン").type("StaticText"), true)
        logd(3)
        sleep(500)
    }
}

// 关闭广告
function closed() {
    laoleng.EC.initNode()
    if (findNode(name("閉じる").type("Button"), true)) {
        logd('点击关闭广告的叉×')
        sleep(200)
    }
}

// 自动滑动
async function autoswiper(maxCount) {
    let startX = 400 // 起始X坐标
    let startY = 600 // 起始Y坐标
    let endX = 400   // 结束X坐标
    let endY = 400   // 结束Y坐标
    let duration = 200 // 滑动持续时间
    let findshopcount = 0    //最大次数为40就结束滑动

    while (findshopcount < maxCount) {
        // 检查条件是否满足
        if (shop_name === "JAPRUN") {
            laoleng.EC.initNode()
            if (findNode(label("JAPRUN 楽天市場店").value("JAPRUN 楽天市場店").depth(23).type("StaticText").visible(true).accessible(true), true)) {
                logd("找到店铺 break：" + (findshopcount + 1) + " " + shop_name)
                sleep(1500)
                break // 条件满足，退出循环
            }
        }

        if (shop_name === "ブルーホエール") {
            laoleng.EC.initNode()
            if (findNode(label("ブルーホエール").value("ブルーホエール").depth(23).type("StaticText").visible(true).accessible(true), true)) {
                logd("找到店铺 break：" + (findshopcount + 1) + " " + shop_name)
                sleep(1500)
                break // 条件满足，退出循环
            }
        }

        if (shop_name === "島ちゃんストア") {
            laoleng.EC.initNode()
            if (findNode(label("島ちゃんストア　楽天市場店").value("島ちゃんストア　楽天市場店").depth(23).type("StaticText").visible(true).accessible(true), true)) {
                logd("找到店铺 break：" + (findshopcount + 1) + " " + shop_name)
                sleep(1500)
                break // 条件满足，退出循环
            }
        }

        // 执行滑动操作
        swipeToPoint(startX, startY, endX, endY, duration);
        findshopcount++
        sleep(2200)
    }
    //不在搜索页面直接关闭
    sleep(100)
    if (findshopcount >= maxCount) {
        console.log("找不到店铺：" + (findshopcount + 1) + " " + shop_name)
        return false
    }
}

//滑动
function huadong() {
    var result = swipeToPoint(400, 600, 400, 400, 200);
    sleep(1000)
}

// 滑动250px
function huadong250() {
    var result = swipeToPoint(400, 600, 400, 350, 500);
    sleep(1000)
}

//购物车页面滑动
function huadongbuy() {
    var result = swipeToPoint(400, 600, 400, 300, 200);
    sleep(1000)
}

//滑动2
function huadong_big() {
    var result = swipeToPoint(400, 950, 400, 200, 200);
    sleep(1000)
}

//滑动
function huadong_shang() {
    var result = swipeToPoint(400, 400, 400, 800, 200);
    sleep(1000)
}

function input_keyword(keyword) {
    var result = inputText(keyword, 500);
}


function an_enter() {
    let x = ioHIDEvent("0x07", "0x58", 0.2)
    sleep(2000);

}

function an_tabl() {
    let x = ioHIDEvent("0x07", "0x2B", 0.2)
    sleep(2000);
}

function an_delete() {
    let x = ioHIDEvent("0x07", "0x2A", 0.2)

}

function input_delete() {
    clickPoint(86, 330);
    sleep(1000);
    clickPoint(86, 330);
    sleep(1000);
    click_image_result8("quanxuan.png")
    sleep(500);
    click_image_result8("jianqie.png")
    sleep(500);

}

//  插入的方法结束---------------------------------------------------------------------


//  登录的步骤---------------------------------------------------------------------------

//开始登录账户
function rakuten_login_acc() {
    sleep(500)
    closed()
    //初始化节点，不然无法使用
    laoleng.EC.initNode()
    sleep(500)
    if (findNode(name("ログイン").type("Button"), true)) {
        logd("首次登录账户");
        sleep(3000);
        //查找节点并点击   邮箱账户输入  疑似点击不到
        if (findNode(name("ユーザIDを入力してください").label("ユーザIDを入力してください").type("TextField"), true)) {
            input_keyword(acc_email)
            sleep(1000)
        }
        sleep(1500)
        //密码输入
        if (findNode(name("パスワードを入力してください").label("パスワードを入力してください").type("SecureTextField"), true)) {
            sleep(200)
            input_keyword(acc_pass)
            sleep(500)
        }

        //点击button按钮
        if (findNode(name("ログイン").type("Button"), true)) {
            console.log('登录账户')
            sleep(3000);
        }

        //判断//是否登录失败
        laoleng.EC.initNode()
        if (findNode(name("ユーザID、パスワードの入力に誤りがあるか登録されていません。再度ログインしてください。").type("StaticText"))) {
            console.log('登录中判断是否存在该字条')
            logd("邮箱密码错误: " + acc_email);
            //回传提交数据
            let result = update_login_fail();
            if (result != 'null') {
                console.log('成功回传邮箱密码有误')
            }
            return true
            // //关闭乐天app
            // closeapp("jp.co.rakuten.ichiba")
            // sleep(200)
            // return console.log("关闭app之后")

        } else if (findNode(name("インターネット接続がオフラインのようです").type("StaticText"))) {
            sleep(100)
            logd('网络断开连接')
            return true
        }

        //关闭广告
        closed()
        sleep(200);
    } else {
        logd("不在登录账户页面");
    }
    sleep(100)
    logd('登录结束')
}

//判断购物车是否有商品，搜索产品并点击到该产品页面
function click_search_cp() {

    sleep(200)
    //  点击广告的 x
    closed()
    sleep(200)
    logd('进入产品阶段')
    laoleng.EC.initNode()
    // 购物车
    if (findNode(label("買い物かご").name("ai.cart").type("Button"))) {
        logd('购物车')
        if (findNode(name("Icon.TabBar.Rex.Cart").id("Icon.TabBar.Rex.Cart").type("Image"))) {
            if (g_ret && g_ret.childCount > 0) {

                //     }
                // }
                // let Cartimages = name("Icon.TabBar.Rex.Cart").id("Icon.TabBar.Rex.Cart").type("Image").depth(7).index(0).getOneNodeInfo(10000)
                // sleep(1000)
                // if (Cartimages && Cartimages.childCount > 0) {
                // 获得购物车的数量
                let cartnum = g_ret.child().value
                logd(cartnum)
                g_ret.clickCenter()
                // 点击购物车后需要加载的时间
                sleep(7000)
                if (findNode(label("買い物かご").type("Other").depth(20))) {
                    sleep(1000)
                    for (let i = 0; i < cartnum; i++) {
                        if (findNode(label("削除する").type("Link").depth(21).index(0), true)) {
                            sleep(2000)
                        }
                    }
                } else {
                    logd('没有进入购物车页面')
                    sleep(100)
                }

                if (findNode(label("ホーム").name("ai.home").type("Button").depth(6).index(1), true)) {
                    logd('返回首页')
                    sleep(1000)
                } else {
                    logd('未返回首页')
                    sleep(100)
                }
            } else {
                logd('购物车没有商品')
            }
        }
    }

    //1.点击首页搜索框框
    let node = name("キーワード検索").label("キーワード検索").type("SearchField").getOneNodeInfo(10000)
    if (node) {
        logd(node.clickCenter())

        logd("搜索产品点到产品页面")
        sleep(1000);
        //2.输入关键词
        input_keyword(keyword);
        logd("输入关键词: " + keyword);
        //回车
        an_enter();
        sleep(2000);

        //点击店铺名称
        logd(shop_name)
        autoswiper(40)

    } else {
        logd("未点击搜索框");
    }
}

//产品页面属性的选择
function click_cp_attribute() {
    //初始化节点
    //新
    laoleng.EC.initNode()
    if (findNode(name("商品詳細").type("StaticText"))) {
        huadong();
        sleep(1000);
        huadong();
        sleep(1000);
        logd("点购物 在产品页面");
        let addincart = click_addcart()
        if (addincart != "null") {
            sleep(4000)
            let shopdetail = name("商品詳細を選択").type("StaticText").getOneNodeInfo(10000)
            if (shopdetail) {
                logd('这是商品详细选择页面')
                if (findNode(name("商品詳細").type("TextView"))) {
                    logd('有商品属性')
                    //获得 未選択 的个数
                    let unselected = label("未選択").type("StaticText").getNodeInfo(10000)

                    //这是商品属性
                    if (unselected) {
                        for (let i = 0; i < unselected.length; i++) {
                            //获得各个 未選択 下面的选择器
                            let attrs = nameMatch("VariantSelectorView_.*.ScrollView").type("ScrollView").getNodeInfo(10000)
                            if (attrs) {
                                //选择器下的Other
                                let attr = attrs[i].child(0).allChildren()
                                attr[random(0, attr.length - 1)].clickCenter()
                                sleep(500)
                            }
                        }

                        sleep(2000)
                        huadong()
                        sleep(1500)
                    }

                    //有 (必須) 才进入点击
                    let req = valueMatch(".*(必須)").type("TextView").getNodeInfo(10000)
                    if (req) {
                        //这是必须要选
                        let dom = name("選択してください").type("Button").getNodeInfo(10000)
                        if (dom) {
                            for (let i = 0; i < dom.length; i++) {
                                sleep(500)
                                dom[i].clickCenter()
                                sleep(500)

                                let havetab = type("Cell").depth('7').getNodeInfo(10000)
                                if (havetab) {
                                    let rod = random(1, havetab.length)
                                    let clickCell = findNode(type("Cell").depth('7').index(rod), true)
                                    if (!clickCell) {
                                        logd('点击选项失败' + rod)
                                        sleep(500)
                                    }
                                }
                            }

                            sleep(1000)
                            huadong()
                            sleep(4100)
                        }

                        findNode(labelMatch(".*(必須)").type("StaticText"), true)

                        laoleng.EC.initNode()
                        if (findNode(name("了解した").type("StaticText"), true)) {
                            logd("点击没有句号的了解")
                        }
                        findNode(labelMatch(".*(必須)").type("StaticText"), true)

                        laoleng.EC.initNode()
                        if (findNode(name("了解した。").value("了解した。").type("StaticText"), true)) {
                            logd("点击有句号的了解")
                        }
                        // let lastop = name("了解した。").value("了解した。").type("StaticText").getOneNodeInfo(10000)
                        // if (lastop) {
                        //     lastop.clickCenter()
                        //     sleep(500)
                        // } else {
                        //     logd("没有点击有句号的了解")
                        // }
                        sleep(300)
                        //点击购物
                        click_addcart()//加入购物车
                        laoleng.EC.initNode()
                        sleep(800)
                        if (findNode(label("OK").type("Button").depth(11).index(0), true)) {
                            logd('点击了ok按钮')
                            sleep(500)
                            //这是必须要选
                            let dom = name("選択してください").type("Button").getNodeInfo(10000)
                            if (dom) {
                                for (let i = 0; i < dom.length; i++) {
                                    sleep(500)
                                    dom[i].clickCenter()
                                    sleep(500)

                                    let havetab = type("Cell").depth('7').getNodeInfo(10000)
                                    if (havetab) {
                                        let rod = random(1, havetab.length)
                                        let clickCell = findNode(type("Cell").depth('7').index(rod), true)
                                        if (!clickCell) {
                                            logd('点击选项失败' + rod)
                                            sleep(500)
                                        }
                                    }
                                }

                                sleep(1000)
                                huadong()
                                sleep(4100)
                            }

                            findNode(labelMatch(".*(必須)").type("StaticText"), true)

                            laoleng.EC.initNode()
                            if (findNode(name("了解した").type("StaticText"), true)) {
                                logd("点击没有句号的了解")
                            }
                            findNode(labelMatch(".*(必須)").type("StaticText"), true)

                            laoleng.EC.initNode()
                            if (findNode(name("了解した。").value("了解した。").type("StaticText"), true)) {
                                logd("点击有句号的了解")
                            }
                            sleep(500)
                            //点击购物
                            click_addcart()//加入购物车
                            sleep(4000)
                        } else {
                            sleep(4000)
                        }

                    } else {
                        sleep(500)
                        //点击购物
                        click_addcart()//加入购物车
                        sleep(4000)
                    }
                } else {    //若是没有sku属性，而有较少的选项式那点击ok后会有重新进行选择
                    //有 (必須) 才进入点击
                    let req = valueMatch(".*(必須)").type("TextView").getNodeInfo(10000)
                    if (req) {
                        //这是必须要选
                        let dom = name("選択してください").type("Button").getNodeInfo(10000)
                        if (dom) {
                            for (let i = 0; i < dom.length; i++) {
                                sleep(500)
                                dom[i].clickCenter()
                                sleep(500)

                                let havetab = type("Cell").depth('7').getNodeInfo(10000)
                                if (havetab) {
                                    let rod = random(1, havetab.length)
                                    let clickCell = findNode(type("Cell").depth('7').index(rod), true)
                                    if (!clickCell) {
                                        logd('点击选项失败' + rod)
                                        sleep(500)
                                    }
                                }
                            }

                            sleep(1000)
                            huadong()
                            sleep(3800)
                        }

                        findNode(labelMatch(".*(必須)").type("StaticText"), true)

                        laoleng.EC.initNode()
                        if (findNode(name("了解した").type("StaticText"), true)) {
                            logd("点击没有句号的了解")
                        }
                        findNode(labelMatch(".*(必須)").type("StaticText"), true)

                        laoleng.EC.initNode()
                        let lastop = name("了解した。").value("了解した。").accessible(true).getOneNodeInfo(10000)
                        if (lastop) {
                            lastop.clickRandom()
                            sleep(200)
                        } else {
                            logd("没有点击有句号的了解")
                        }
                        sleep(500)
                        //点击购物
                        click_addcart()//加入购物车
                        laoleng.EC.initNode()
                        sleep(800)
                        if (findNode(label("OK").type("Button").depth(11).index(0), true)) {
                            logd('点击了ok按钮')
                            sleep(800)
                            //这是必须要选
                            let dom = name("選択してください").type("Button").getNodeInfo(10000)
                            if (dom) {
                                for (let i = 0; i < dom.length; i++) {
                                    sleep(500)
                                    dom[i].clickCenter()
                                    sleep(500)

                                    let havetab = type("Cell").depth('7').getNodeInfo(10000)
                                    if (havetab) {
                                        let rod = random(1, havetab.length)
                                        let clickCell = findNode(type("Cell").depth('7').index(rod), true)
                                        if (!clickCell) {
                                            logd('点击选项失败' + rod)
                                            sleep(500)
                                        }
                                    }
                                }

                                sleep(1000)
                                huadong()
                                sleep(4100)
                            }
                            laoleng.EC.initNode()
                            findNode(labelMatch(".*(必須)").type("StaticText"), true)
                            if (findNodeAll(nameMatch("了解.*").type("StaticText").accessible(true).visible(true))) {
                                for (let i = 0; i < gNodeAll.length; i++) {
                                    logd(JSON.stringify(gNodeAll[i]))
                                    //点击
                                    gNodeAll[i].clickCenter()
                                    sleep(500)
                                }
                            } else {
                                console.log('没有找到')
                            }
                            sleep(500)
                            //点击购物
                            click_addcart()//加入购物车
                            sleep(4000)
                        } else {
                            sleep(4000)
                        }

                    } else {
                        sleep(500)
                        //点击购物
                        click_addcart()//加入购物车
                        sleep(4000)
                    }
                }
            } else {
                logd('该商品没有属性，跳过属性选择')
                sleep(300)
            }

        } else {
            logd("没有找到添加购物车按钮");
        }
        sleep(2000)
        // click_addcart()//加入购物车
    } else {
        logd("不在产品页面")
    }
}

//判断是否在购物车页面
function cart_page() {
    laoleng.EC.initNode()
    let incart = name("買い物かご").type("Other").getOneNodeInfo(10000)
    if (incart) {
        //到达购物车页面
        if (findNode(label("削除する").type("Link").index(0))) {
            sleep(2000)
            huadongbuy();
            sleep(4200)
            laoleng.EC.initNode()
            if (findNode(name("購入手続き").label("購入手続き").type("Button"), true)) {
                sleep(2000);
            }
            sleep(2000)
        } else {
            logd('还没完全加载购物车页面')
        }
    } else {
        logd('未进入购物车结算页面')
    }
}

//判断是否在输入密码页面
function login_rg_page() {
    iphone_1 = '090'
    iphone_2 = get4random()
    iphone_3 = get4random()
    laoleng.EC.initNode()
    setFetchNodeParam({
        "labelFilter": "1",
        "maxDepth": "60",
        "visibleFilter": "1",
        "excludedAttributes": ""
    })
    sleep(800)
    //密码输入
    if (findNode(value("パスワード").type("SecureTextField"), true)) {
        logd('这里输入密码')
        input_keyword(acc_pass)
        sleep(2000)

        //按钮    楽天会員の方はこちら
        if (findNode(name("楽天会員の方はこちら").label("楽天会員の方はこちら").type("Button"), true)) {
            console.log('点击了button')
            sleep(3000)
        }
        sleep(4000)
        if (findNode(label("会員情報の追加登録").type("StaticText").depth(23))) {
            findNode(type("TextField").depth(23).index(0), true)
            sleep(700);
            input_keyword(iphone_1);
            sleep(500);
            an_tabl()
            sleep(400);
            input_keyword(iphone_2);
            sleep(500);
            an_tabl()
            sleep(400);
            input_keyword(iphone_3);
            sleep(300);
            findNode(label("携帯電話のみお持ちの方は、携帯電話の番号を入力してください。").type("StaticText"), true)
            findNode(label("以下の規約に同意して追加内容を確認する").type("Button"), true)
            sleep(3000)
            if (findNode(label("入力内容の確認").type("StaticText"))) {
                sleep(500)
                huadong()
                sleep(2000)
                let ofpwd = label("<半角英数字>").type("StaticText").getOneNodeInfo(10000)
                if (ofpwd) {
                    let inputpwd = ofpwd.parent().nextSiblings()[0].child(0)
                    if (inputpwd) {
                        inputpwd.clickCenter()
                        sleep(2000)
                        logd('这里输入密码')
                        input_keyword(acc_pass)
                        sleep(2000)
                    }
                }
                sleep(500)
                findNode(label("会員情報を追加登録する").type("Button"), true)
                sleep(2000)
                findNode(label("続けてサービスを利用する").type("Button"), true)
                sleep(8000)

                // //判断//选支付确认页面
                // add_payment_conf()
                //
                // //判断//获取订单号
                // success_order()
                // // return false
                // //关闭乐天app
                // sleep(500)
                // closeapp("jp.co.rakuten.ichiba")
                // sleep(100)
                //
                // return false
            }
        } else if (findNode(name("ユーザID、パスワードの入力に誤りがあるか登録されていません。再度ログインしてください。").type("StaticText"))) {
            //判断是否登录失败
            console.log('登录中判断是否存在该字条')
            logd("邮箱密码错误: " + acc_email);
            //回传提交数据
            update_login_fail();
            sleep(1000)

            //关闭乐天app
            sleep(500)
            closeapp("jp.co.rakuten.ichiba")
            sleep(200)
            return console.log("关闭app之后")
        } else {
            sleep(100)
        }
    } else {
        if (findNode(label("要求がタイムアウトしました").type("StaticText").depth(21)) && findNode(label("良好な通信環境でもう一度お試しください").type("StaticText").depth(21))) {
            // if (findNode(label("再読み込み").type("Button"), true)) {
            //
            // }
            sleep(100)
            logd('未知原因导致网络中断')
        }
    }
}

//选择支付方式页面
function add_payment() {
    laoleng.EC.initNode()
    sleep(1200)
    if (findNode(name("支払い方法の選択").type("Other"))) {
        logd("在选支付页面");
        sleep(200);
        var randnum = random(1, 4)
        if (randnum === 1) {
            huadong()
            let ofother = findNode(name("コンビ二・郵便局等").type("StaticText"), true)
            if (!ofother) {
                logd('点击郵便局失败')
            }
            sleep(200);
            let firstch = findNode(name("セブンイレブン（前払）").type("StaticText"), true)
            if (!firstch) {
                logd('点击郵便局第一个选项失败')
            }
            sleep(200);
            huadong()
        } else if (randnum === 2) {
            huadong()
            let ofother = findNode(name("コンビ二・郵便局等").type("StaticText"), true)
            if (!ofother) {
                logd('点击郵便局失败')
            }
            sleep(200);
            let secondch = findNode(name("ローソン、郵便局ATM等（前払）").type("StaticText"), true)
            if (!secondch) {
                logd('点击郵便局第二个选项失败')
            }
            sleep(200);
            huadong()
        } else if (randnum === 3) {
            let clickbank = findNode(name("銀行振込").type("StaticText"), true)
            if (!clickbank) {
                logd('点击bank支付失败')
            }
            sleep(200);
            huadong()
            sleep(200);
        } else if (randnum === 4) {
            let clickbank = findNode(name("銀行振込").type("StaticText"), true)
            if (!clickbank) {
                logd('点击bank支付失败')
            }
            sleep(200);
            huadong()
            sleep(200);
        }
        huadong()
        sleep(500);
        if (findNode(name("次へ").type("Button"), true)) {
            sleep(1000)
        } else {
            logd('点击确认支付按钮失败')
        }
        sleep(4000)
    } else {
        logd("不在在选中支付页面");
    }
}


//选择支付方式页面
function rakuten_pay_add_payment() {
    laoleng.EC.initNode()
    sleep(1200)
    if (findNode(name("支払い方法の選択").type("Other"))) {
        logd("在选支付页面");
        sleep(200);
        huadong()
        if (pay_select == "711") {
            let ofother = findNode(name("コンビ二・郵便局等").type("StaticText"), true)
            if (!ofother) {
                logd('点击郵便局失败')
            }
            sleep(200);
            let firstch = findNode(name("セブンイレブン（前払）").type("StaticText"), true)
            if (!firstch) {
                logd('点击郵便局第一个选项失败')
            }
            sleep(200);
            huadong()
        }

        if (pay_select == "ls") {
            huadong()
            let ofother = findNode(name("コンビ二・郵便局等").type("StaticText"), true)
            if (!ofother) {
                logd('点击郵便局失败')
            }
            sleep(200);
            let secondch = findNode(name("ローソン、郵便局ATM等（前払）").type("StaticText"), true)
            if (!secondch) {
                logd('点击郵便局第二个选项失败')
            }
            sleep(200);
            huadong()
        }
        huadong()
        sleep(500);
        if (findNode(name("次へ").type("Button"), true)) {
            sleep(1000)
        } else {
            logd('点击确认支付按钮失败')
        }
        sleep(4000)
    } else {
        logd("不在在选中支付页面");
    }
}

//支付确认页面
function rakuten_pay_add_payment_conf() {
    //新
    laoleng.EC.initNode()
    if (findNode(name("注文内容の確認").type("StaticText"))) {
        logd("在确认支付页面");
        huadong()
        sleep(1500)
        if (findNode(name("変更").type("Button"), true)) {
            logd('変更地址')
            sleep(1500)
            if (findNode(name("編集").type("Button"), true)) {
                logd('編集地址')
                sleep(1500)
                if (findNode(label("郵便番号").type("StaticText"))) {
                    let inputpwd = g_ret.parent().nextSiblings()[0]
                    if (inputpwd) {
                        inputpwd.clickCenter()
                    } else {
                        console.log('没有找到地址编码的节点')
                    }
                } else {
                    console.log('没有找到地址编码上方的文字节点')
                }

                ioHIDEvent("0x07", "0x2A", 0.2)
                ioHIDEvent("0x07", "0x2A", 0.2)
                ioHIDEvent("0x07", "0x2A", 0.2)
                ioHIDEvent("0x07", "0x2A", 0.2)
                ioHIDEvent("0x07", "0x2A", 0.2)
                ioHIDEvent("0x07", "0x2A", 0.2)
                ioHIDEvent("0x07", "0x2A", 0.2)

                sleep(500);
                input_keyword(post);
                sleep(3000);
                input_keyword(address);
                sleep(500);
            }
        } else {
            logd('第一次点击支付失败')
            huadong_big()
            huadong_big()
            huadong_big()
            huadong_big()
            if (findNode(name("注文を確定する").type("Button"), true)) {
                sleep(5000)
                click_tanchuan()
            } else {
                logd('第二次点击支付失败')
            }
        }
    } else {
        logd("不在确认支付页面");
    }
}

//支付确认页面
function add_payment_conf() {
    //新
    laoleng.EC.initNode()
    if (findNode(name("注文内容の確認").type("StaticText"))) {
        logd("在确认支付页面");
        huadong()
        sleep(1500)
        if (findNode(name("注文を確定する").type("Button"), true)) {
            logd('第一次点击支付成功')
            sleep(5000)
            click_tanchuan()
        } else {
            logd('第一次点击支付失败')
            huadong_big()
            huadong_big()
            huadong_big()
            huadong_big()
            if (findNode(name("注文を確定する").type("Button"), true)) {
                sleep(5000)
                click_tanchuan()
            } else {
                logd('第二次点击支付失败')
            }
        }
    } else {
        logd("不在确认支付页面");
    }
}

//获取订单号并回传页面
function success_order() {
    laoleng.EC.initNode()
    sleep(1000)
    click_tanchuan()
    logd("点击last今はしない")
    sleep(500)
    if (findNode(name("注文内容がショップに送信されました。"))) {
        closed()
        logd("在订单页面")
        //今はしない
        click_tanchuan()
        logd("点击last今はしない")
        sleep(500)
        acc_order = get_text()
        if (acc_order) {
            logd(acc_order);

            //回传提交数据
            // updateinventory(acc_order);
            sleep(200)

            //回传订单号
            updateorderid(acc_order, sku)
            sleep(200)

            //回传 记录邮箱使用
            updateemail_static()
            sleep(200)
        } else {
            utfind(name("今はしない"), 1000, true, 8)
            acc_order = get_text()
            logd(acc_order);

            //回传提交数据
            // updateinventory(acc_order);
            sleep(200)

            //回传订单号
            updateorderid(acc_order, sku)
            sleep(200)

            //回传 记录邮箱使用
            updateemail_static()
            sleep(200)
        }
        if (findNode(name("注文内容がショップに送信されました。"))) {
            logd("订单页面，来关闭")
            sleep(300)
            findNode(label("Close").name("Close").type("Button"), true)
            sleep(500);

            //登录账户
            logd("订单页面，登录");
            sleep(200);
            //今はしない
            click_tanchuan()
            logd("点击首页今はしない");
            sleep(300);
            click_tanchuan()
            logd("点击首页今はしない");
            sleep(200);
            closed()
            sleep(200);

            if (findNode(label("購入履歴").name("ai.purchaseHistory").type("Button"), true)) {
                sleep(800);
                if (findNode(label("購入履歴").value("購入履歴").type("StaticText"))) {
                    sleep(500);
                } else {
                    if (findNode(name("ログイン").type("Button"), true)) {
                        logd("購入履歴界面登录账户");

                        sleep(500)
                        //查找节点并点击   邮箱账户输入
                        if (findNode(name("ユーザIDを入力してください").label("ユーザIDを入力してください").type("TextField"), true)) {
                            input_keyword(acc_email)
                            sleep(1000)
                        }
                        sleep(1000)
                        //密码输入
                        if (findNode(name("パスワードを入力してください").label("パスワードを入力してください").type("SecureTextField"), true)) {
                            sleep(200)
                            input_keyword(acc_pass)
                            sleep(500)
                        }
                        //点击button按钮
                        if (findNode(name("ログイン").type("Button"), true)) {
                            console.log('登录账户')
                            sleep(500);
                        }
                        sleep(2000)
                    }
                }
            }

            new_iphone_new_name();
            sleep(500)
        } else {
            logd("不在历史登陆页面");
        }

    } else {
        logd("可能弹窗影响，没有找到订单号");
        utfind(name("今はしない"), 1000, true, 3)
        var orderid = get_text()
        logd(orderid);

        //回传提交数据
        // updateinventory(orderid);
        sleep(200)

        //回传订单号
        updateorderid(orderid, sku)
        sleep(200)

        //回传 记录邮箱使用
        updateemail_static()
        sleep(200)

        new_iphone_new_name();
        sleep(500)
    }
}

//  登录的步骤结束---------------------------------------------------------------------------

//点击shopname
function click_shopname(imaname) {
    //从工程目录下res文件夹下读取sms.png文件
    let sms = readResAutoImage(imaname);
    //抓取屏幕
    let aimage = image.captureFullScreen();
    // logd("aimage " + aimage);
    if (aimage != null) {
        //在图片中查找
        let points = image.findImage(aimage, sms, 0, 0, 0, 0, 0.7, 0.9, 1, 5);
        logd(imaname + " 图片点击 " + JSON.stringify(points));
        //这玩意是个数组
        if (points && points.length > 0) {
            for (let i = 0; i < points.length; i++) {
                // logd(points[i])
                let x = parseInt((points[i].left + points[i].right) / 2)
                let y = parseInt((points[i].top + points[i].bottom) / 2)
                //点击坐标
                sleep(500);
                clickPoint(x, y)
                sleep(1000);
                return "找到图片";
            }
        } else {
            return "搜索不到图片";

        }
        //图片要回收
        image.recycle(aimage)
    }
    //图片要回收
    image.recycle(sms)
}

//点击图片
function click_image(imaname) {
    //从工程目录下res文件夹下读取sms.png文件
    let sms = readResAutoImage(imaname);
    //抓取屏幕
    let aimage = image.captureFullScreen();
    // logd("aimage " + aimage);
    if (aimage != null) {
        //在图片中查找
        let points = image.findImage(aimage, sms, 0, 0, 0, 0, 0.5, 0.5, 1, 5);
        logd(imaname + " 图片点击 " + JSON.stringify(points));
        //这玩意是个数组
        if (points && points.length > 0) {
            for (let i = 0; i < points.length; i++) {
                // logd(points[i])
                let x = parseInt((points[i].left + points[i].right) / 2)
                let y = parseInt((points[i].top + points[i].bottom) / 2)
                //点击坐标
                clickPoint(x, y)
                sleep(500);
            }
        }
        //图片要回收
        image.recycle(aimage)
    }
    //图片要回收
    image.recycle(sms)
}

//点击图片
function click_image_result(imaname) {
    logd(imaname + " 图片点击 ");
    //从工程目录下res文件夹下读取sms.png文件
    let sms = readResAutoImage(imaname);
    //抓取屏幕
    let aimage = image.captureFullScreen();
    // logd("aimage " + aimage);
    if (aimage != null) {
        //在图片中查找
        let points = image.findImage(aimage, sms, 0, 0, 0, 0, 0.5, 0.5, 1, 5);
        logd(imaname + " 图片点击 " + JSON.stringify(points));
        //这玩意是个数组
        if (points && points.length > 0) {
            for (let i = 0; i < points.length; i++) {
                // logd(points[i])
                let x = parseInt((points[i].left + points[i].right) / 2)
                let y = parseInt((points[i].top + points[i].bottom) / 2)
                //点击坐标
                sleep(200);
                clickPoint(x, y)
                sleep(500);
                return "yes";
            }
        } else {
            return "no";
        }
        //图片要回收
        image.recycle(aimage)
    }
    //图片要回收
    image.recycle(sms)
    let img1 = image.captureFullScreen()
    laoleng.img.recycle(img1)

    sleep(500);
}

//点击图片
function pd_image_result6(imaname) {
    //从工程目录下res文件夹下读取sms.png文件
    let sms = readResAutoImage(imaname);
    //抓取屏幕
    let aimage = image.captureFullScreen();
    // logd("aimage " + aimage);
    if (aimage != null) {
        //在图片中查找
        let points = image.findImage(aimage, sms, 0, 0, 0, 0, 0.6, 0.6, 1, 5);
        logd(imaname + " 图片点击 " + JSON.stringify(points));
        //这玩意是个数组
        if (points && points.length > 0) {
            for (let i = 0; i < points.length; i++) {
                // logd(points[i])
                let x = parseInt((points[i].left + points[i].right) / 2)
                let y = parseInt((points[i].top + points[i].bottom) / 2)
                return "yes";
            }
        } else {
            return "no";
        }
        //图片要回收
        image.recycle(aimage)
    }
    //图片要回收
    image.recycle(sms)

    sleep(500);
}

//点击图片
function pd_image_result7(imaname) {
    //从工程目录下res文件夹下读取sms.png文件
    let sms = readResAutoImage(imaname);
    //抓取屏幕
    let aimage = image.captureFullScreen();
    // logd("aimage " + aimage);
    if (aimage != null) {
        //在图片中查找
        let points = image.findImage(aimage, sms, 0, 0, 0, 0, 0.7, 0.7, 1, 5);
        logd(imaname + " 图片点击 " + JSON.stringify(points));
        //这玩意是个数组
        if (points && points.length > 0) {
            for (let i = 0; i < points.length; i++) {
                // logd(points[i])
                let x = parseInt((points[i].left + points[i].right) / 2)
                let y = parseInt((points[i].top + points[i].bottom) / 2)
                return "yes";
            }
        } else {
            return "no";
        }
        //图片要回收
        image.recycle(aimage)
    }
    //图片要回收
    image.recycle(sms)

    sleep(500);
}

//点击图片
function pd_image_result8(imaname) {
    //从工程目录下res文件夹下读取sms.png文件
    let sms = readResAutoImage(imaname);
    //抓取屏幕
    let aimage = image.captureFullScreen();
    // logd("aimage " + aimage);
    if (aimage != null) {
        //在图片中查找
        let points = image.findImage(aimage, sms, 0, 0, 0, 0, 0.8, 0.8, 1, 5);
        logd(imaname + " 图片点击 " + JSON.stringify(points));
        //这玩意是个数组
        if (points && points.length > 0) {
            for (let i = 0; i < points.length; i++) {
                // logd(points[i])
                let x = parseInt((points[i].left + points[i].right) / 2)
                let y = parseInt((points[i].top + points[i].bottom) / 2)
                return "yes";
            }
        } else {
            return "no";
        }
        //图片要回收
        image.recycle(aimage)
    }
    //图片要回收
    image.recycle(sms)

    sleep(500);
}

//点击图片
function click_image_result8(imaname) {
    //从工程目录下res文件夹下读取sms.png文件
    let sms = readResAutoImage(imaname);
    //抓取屏幕
    let aimage = image.captureFullScreen();
    // logd("aimage " + aimage);
    if (aimage != null) {
        //在图片中查找
        let points = image.findImage(aimage, sms, 0, 0, 0, 0, 0.82, 0.82, 2, 5);
        logd(imaname + " 图片点击 " + JSON.stringify(points));
        //这玩意是个数组
        if (points && points.length > 0) {
            for (let i = 0; i < points.length; i++) {
                // logd(points[i])
                let x = parseInt((points[i].left + points[i].right) / 2)
                let y = parseInt((points[i].top + points[i].bottom) / 2)
                //点击坐标
                sleep(500);
                clickPoint(x, y)
                sleep(1000);
                return "yes";
            }
        } else {
            return "no";
        }
        //图片要回收
        image.recycle(aimage)
    }
    //图片要回收
    image.recycle(sms)

    sleep(500);
}

//点击图片
function click_image_result7(imaname) {
    //从工程目录下res文件夹下读取sms.png文件
    let sms = readResAutoImage(imaname);
    //抓取屏幕
    let aimage = image.captureFullScreen();
    // logd("aimage " + aimage);
    if (aimage != null) {
        //在图片中查找
        let points = image.findImage(aimage, sms, 0, 0, 0, 0, 0.7, 0.7, 1, 5);
        logd(imaname + " 图片点击 " + JSON.stringify(points));
        //这玩意是个数组
        if (points && points.length > 0) {
            for (let i = 0; i < points.length; i++) {
                // logd(points[i])
                let x = parseInt((points[i].left + points[i].right) / 2)
                let y = parseInt((points[i].top + points[i].bottom) / 2)
                //点击坐标
                clickPoint(x, y)
                return "yes";
            }
        } else {
            return "no";
        }
        //图片要回收
        image.recycle(aimage)
    }
    //图片要回收
    image.recycle(sms)
    let img1 = image.captureFullScreen()
    laoleng.img.recycle(img1)
    sleep(500);
}

function click_image_range(imaname) {
    //从工程目录下res文件夹下读取sms.png文件
    let sms = readResAutoImage(imaname);
    //抓取屏幕
    let aimage = image.captureFullScreen();
    // logd("aimage " + aimage);
    if (aimage != null) {
        //在图片中查找
        let points = image.findImage(aimage, sms, 0, 0, 0, 0, 0.7, 0.7, 1, 5);
        logd(imaname + " 图片点击 " + JSON.stringify(points));
        var temp = random(0, 4) * 126
        //这玩意是个数组
        if (points && points.length > 0) {
            for (let i = 0; i < points.length; i++) {
                // logd(points[i])
                let x = parseInt((points[i].left + points[i].right) / 2)
                let y = parseInt((points[i].top + points[i].bottom) / 2)
                //点击坐标
                clickPoint(x + temp, y + 100)
                return "yes";
            }
        } else {
            return "no";
        }
        //图片要回收
        image.recycle(aimage)
    }
    //图片要回收
    image.recycle(sms)
    let img1 = image.captureFullScreen()
    laoleng.img.recycle(img1)
    sleep(500);
}

//点击图片
function click_image_test() {
    //从工程目录下res文件夹下读取sms.png文件
    let sms = readResAutoImage("bluewhale.png");
    //抓取屏幕
    let aimage = image.captureFullScreen();
    // logd("aimage " + aimage);
    if (aimage != null) {
        //在图片中查找
        let points = image.findImage(aimage, sms, 0, 0, 0, 0, 0.5, 0.5, 1, 5);
        logd(JSON.stringify(points));
        //这玩意是个数组
        if (points && points.length > 0) {
            for (let i = 0; i < points.length; i++) {
                // logd(points[i])
                let x = parseInt((points[i].left + points[i].right) / 2)
                let y = parseInt((points[i].top + points[i].bottom) / 2)
                //点击坐标
                sleep(500);
                clickPoint(x, y)
                sleep(1000);
            }
        }
        //图片要回收
        image.recycle(aimage)
    }
    //图片要回收
    image.recycle(sms)

    sleep(500);
}

//判断是否到产品页面
function text_pd(textkey) {
    setFetchNodeParam({
        "labelFilter": "2",
        "maxDepth": "70",
        "visibleFilter": "2",
        "excludedAttributes": "visible,2"
    })
    let node = name(textkey).getOneNodeInfo(10000)
    logd(JSON.stringify(node))
    return node;
}

//判断是否到产品页面
function text_pd(textkey) {
    setFetchNodeParam({
        "labelFilter": "2",
        "maxDepth": "70",
        "visibleFilter": "2",
        "excludedAttributes": "visible,2"
    })
    let node = name(textkey).getOneNodeInfo(10000)
    logd(JSON.stringify(node))
    return node;
}

//文字点击
function click_text(textkey) {
    setFetchNodeParam({
        "labelFilter": "2",
        "maxDepth": "70",
        "visibleFilter": "2",
        "excludedAttributes": "visible,2"
    })
    let node = name(textkey).getOneNodeInfo(10000)
    logd(JSON.stringify(node))
    return node;
}

//识图 返回订单id
function get_text() {
    let appleVision = {"type": "appleVision", "level": "accurate", "languages": "zh-Hans,en-US"}
    let inited = ocr.initOcr(appleVision)
    logd("初始化结果 -" + inited);
    if (!inited) {
        loge("error : " + ocr.getErrorMsg());
        return;
    }

    for (var ix = 0; ix < 1; ix++) {

        //读取一个bitmap
        let img = image.captureFullScreen();
        if (img == null || img == undefined || img.uuid == null || img.uuid == undefined || img.uuid == "") {
            loge("读取图片失败");
            continue;
        }
        console.time("1")
        logd("start---ocr");
        // 对图片进行识别
        let result = ocr.ocrImage(img, 20 * 1000, {});
        // 112233
        logd(result)
        if (result) {
            logd("ocr结果-》 " + JSON.stringify(result));
            // logd(result[0].lable)
            for (var i = 0; i < result.length; i++) {
                var value = result[i];
                var orderid = value.label
                if (orderid.includes("注文番号")) {
                    var orderid = orderid.replace("注文番号：", "")

                    return orderid;
                }
            }
        } else {
            logw("未识别到结果");
        }
        image.recycle(img)
        sleep(1000);
    }
    //释放所有资源
    ocr.releaseAll();
}


//关闭app
function stopApp() {
    let set = tjCenter.setCenterUrl("http://192.168.2.6:8020")
    if (set == null || set == "") {
        logd("setCenterUrl  成功: " + set)
    } else {
        logd("setCenterUrl  失败: " + set)
        return
    }
    logd("current deviceId : " + deviceId)

    let stopApp = tjCenter.stopApp(deviceId, "jp.co.rakuten.ichiba")
    if (stopApp == null || stopApp == "") {
        logd("stopApp  成功")
    } else {
        logd("stopApp  失败: " + stopApp)
        return
    }
}


//找图 加入购物车
function addcart() {
    //从工程目录下res文件夹下读取sms.png文件
    let sms = readResAutoImage("addcart.png");
    //在当前屏幕中查找，并且限制只查找一个
    let points = image.findImageEx(sms, 6, 900, 720, 1300, 0.7, 0.9, 1, 5);
    logd("points " + JSON.stringify(points));
    //这玩意是个数组
    if (points && points.length > 0) {
        for (let i = 0; i < points.length; i++) {
            logd(points[i])
            let x = parseInt((points[i].left + points[i].right) / 2)
            let y = parseInt((points[i].top + points[i].bottom) / 2)
            //点击坐标
            clickPoint(x, y)
        }
    }
    //图片要回收
    image.recycle(sms)
}


//找图点击
function click_images_123(images, yd, y) {
    //从工程目录下res文件夹下读取sms.png文件
    let sms = readResAutoImage(images);
    //在当前屏幕中查找，并且限制只查找一个
    let points = image.findImageEx(sms, 0, 0, 0, 0, yd, yd, y, 5);
    logd("points " + JSON.stringify(points));
    //这玩意是个数组
    if (points && points.length > 0) {
        if (y == 0) {
            y = 0
        } else {
            y = y - 1
        }
        for (let i = y; i < points.length; i++) {
            logd(points[i])
            let x = parseInt((points[i].left + points[i].right) / 2)
            let y = parseInt((points[i].top + points[i].bottom) / 2)
            //点击坐标
            clickPoint(x, y)
            return "yes";
        }
    } else {
        return "no";
    }
    //图片要回收
    image.recycle(sms)
}

//找图判断
function pd_images_123(images, yd, y) {
    //从工程目录下res文件夹下读取sms.png文件
    let sms = readResAutoImage(images);
    //在当前屏幕中查找，并且限制只查找一个
    let points = image.findImageEx(sms, 0, 0, 0, 0, yd, yd, y, 5);
    logd("points " + JSON.stringify(points));
    //这玩意是个数组
    if (points && points.length > 0) {
        if (y == 0) {
            y = 0
        } else {
            y = y - 1
        }
        for (let i = y; i < points.length; i++) {
            // logd(points[i])
            let x = parseInt((points[i].left + points[i].right) / 2)
            let y = parseInt((points[i].top + points[i].bottom) / 2)
            return "yes";
        }
    } else {
        return "no";
    }
    //图片要回收
    image.recycle(sms)
    let img1 = image.captureFullScreen()
    laoleng.img.recycle(img1)
}


//找图 下拉值
function click_select_xiala_values() {
    //从工程目录下res文件夹下读取sms.png文件
    let sms = readResAutoImage("select_xiala_values.png");
    //在当前屏幕中查找，并且限制只查找一个
    let points = image.findImageEx(sms, 0, 0, 0, 0, 0.7, 0.9, 1, 5);
    logd("points " + JSON.stringify(points));
    //这玩意是个数组
    if (points && points.length > 0) {
        for (let i = 0; i < points.length; i++) {
            logd(points[i])
            let x = parseInt((points[i].left + points[i].right) / 2)
            let y = parseInt((points[i].top + points[i].bottom) / 2)
            //点击坐标
            clickPoint(x, y)
        }
    }
    //图片要回收
    image.recycle(sms)
}

function click_size2() {
    //从工程目录下res文件夹下读取sms.png文件
    let sms = readResAutoImage("size1.png");
    //在当前屏幕中查找，并且限制只查找一个
    let points = image.findImageEx(sms, 0, 0, 0, 0, 0.7, 0.85, 2, 5);
    logd("points " + JSON.stringify(points));
    //这玩意是个数组
    if (points && points.length > 0) {
        for (let i = 1; i < points.length; i++) {
            logd(points[i])
            let x = parseInt((points[i].left + points[i].right) / 2)
            let y = parseInt((points[i].top + points[i].bottom) / 2)
            //点击坐标
            clickPoint(x, y)
        }
    }
    //图片要回收
    image.recycle(sms)
    sleep(500);
}

function click_size3() {
    //从工程目录下res文件夹下读取sms.png文件
    let sms = readResAutoImage("size1.png");
    //在当前屏幕中查找，并且限制只查找一个
    let points = image.findImageEx(sms, 0, 0, 0, 0, 0.7, 0.85, 3, 5);
    logd("points " + JSON.stringify(points));
    //这玩意是个数组
    if (points && points.length > 0) {
        for (let i = 2; i < points.length; i++) {
            logd(points[i])
            let x = parseInt((points[i].left + points[i].right) / 2)
            let y = parseInt((points[i].top + points[i].bottom) / 2)
            //点击坐标
            clickPoint(x, y)
        }
    }
    //图片要回收
    image.recycle(sms)
    sleep(500);
}

//找图 判断是否在购物车页面
function click_cart_page() {
    //从工程目录下res文件夹下读取sms.png文件
    let sms = readResAutoImage("cart_page.png");
    //在当前屏幕中查找，并且限制只查找一个
    let points = image.findImageEx(sms, 0, 0, 0, 0, 0.7, 0.9, 1, 5);
    logd("points " + JSON.stringify(points));
    //这玩意是个数组
    if (points && points.length > 0) {
        for (let i = 0; i < points.length; i++) {
            logd(points[i])
            let x = parseInt((points[i].left + points[i].right) / 2)
            let y = parseInt((points[i].top + points[i].bottom) / 2)
            //点击坐标
            clickPoint(x, y)
            return "在购物车页面";
        }
    }
    //图片要回收
    image.recycle(sms)
    sleep(500);
}


//找图 判断是否在登录页面
function click_login() {
    //从工程目录下res文件夹下读取sms.png文件
    let sms = readResAutoImage("buttonlogin.png");
    //在当前屏幕中查找，并且限制只查找一个
    let points = image.findImageEx(sms, 0, 0, 0, 0, 0.7, 0.9, 1, 5);
    logd("points " + JSON.stringify(points));
    //这玩意是个数组
    if (points && points.length > 0) {
        for (let i = 0; i < points.length; i++) {
            logd(points[i])
            let x = parseInt((points[i].left + points[i].right) / 2)
            let y = parseInt((points[i].top + points[i].bottom) / 2)
            //点击坐标
            clickPoint(x, y)
            return "在购物车页面";
        }
    }
    //图片要回收
    image.recycle(sms)
    sleep(500);
}


//找图 点击登录文本框
function click_login_email_txt() {
    //从工程目录下res文件夹下读取sms.png文件
    let sms = readResAutoImage("login_email.png");
    //在当前屏幕中查找，并且限制只查找一个
    let points = image.findImageEx(sms, 0, 0, 0, 0, 0.7, 0.9, 1, 5);
    logd("points " + JSON.stringify(points));
    //这玩意是个数组
    if (points && points.length > 0) {
        for (let i = 0; i < points.length; i++) {
            logd(points[i])
            let x = parseInt((points[i].left + points[i].right) / 2)
            let y = parseInt((points[i].top + points[i].bottom) / 2)
            //点击坐标
            clickPoint(x, y)
            return "在购物车页面";
        }
    }
    //图片要回收
    image.recycle(sms)
    sleep(500);
}


//找图 点击登录文本框
function click_login_pass_txt() {
    //从工程目录下res文件夹下读取sms.png文件
    let sms = readResAutoImage("passtext.png");
    //在当前屏幕中查找，并且限制只查找一个
    let points = image.findImageEx(sms, 0, 0, 0, 0, 0.7, 0.9, 1, 5);
    logd("points " + JSON.stringify(points));
    //这玩意是个数组
    if (points && points.length > 0) {
        for (let i = 0; i < points.length; i++) {
            logd(points[i])
            let x = parseInt((points[i].left + points[i].right) / 2)
            let y = parseInt((points[i].top + points[i].bottom) / 2)
            //点击坐标
            clickPoint(x, y)
            return "在购物车页面";
        }
    }
    //图片要回收
    image.recycle(sms)
    sleep(500);
}


//click_tanchuan() 今はしない
function click_tanchuan() {
    setFetchNodeParam({
        "labelFilter": "2",
        "maxDepth": "70",
        "visibleFilter": "2",
        "excludedAttributes": "visible,2"
    })
    let node = name("今はしない").getOneNodeInfo(10000)
    logd(JSON.stringify(node))
    if (node) {
        logd(node.clickRandom())
    }

}

//click_tanchuan() 今はしない
function click_wenzi() {
    setFetchNodeParam({
        "labelFilter": "2",
        "maxDepth": "70",
        "visibleFilter": "2",
        "excludedAttributes": "visible,2"
    })
    let node = name(click_keyword).getOneNodeInfo(10000)
    logd(JSON.stringify(node))
    if (node) {
        logd(node.clickRandom())
    }

}

//click_tanchuan() キーワード検索
function click_search() {
    setFetchNodeParam({
        "labelFilter": "2",
        "maxDepth": "70",
        "visibleFilter": "2",
        "excludedAttributes": "visible,2"
    })
    let node = name("キーワード検索").getOneNodeInfo(10000)
    logd(JSON.stringify(node))
    if (node) {
        logd(node.clickRandom())
    }

}

//click_tanchuan() 購入手続きへ
function click_addcart() {
    setFetchNodeParam({
        "labelFilter": "2",
        "maxDepth": "70",
        "visibleFilter": "2",
        "excludedAttributes": "visible,2"
    })
    let node = name("購入手続きへ").getOneNodeInfo(10000)
    logd(JSON.stringify(node))
    if (node) {
        logd(node.clickRandom())
    }

}

// 加入购物车后随机挑选属性
function click_attr() {
    setFetchNodeParam({
        "labelFilter": "2",
        "maxDepth": "70",
        "visibleFilter": "2",
        "excludedAttributes": "visible,2"
    })

    let node = name("VariantSelectorView_カラー.ScrollView").getOneNodeInfo(10000)
    logd(JSON.stringify(node))
    console.log(JSON.stringify(node).childCount)
    // if (node) {
    //     logd(node.clickRandom())
    // }
}

async function clickElement() {
    // XPath 表达式
    const xpathExpression = "//node[@type='Application']/node[@type='Window']/node[@type='Other']/node[@type='Other']/node[@type='Other']/node[@type='Other']/node[@type='Other']/node[@type='Other']/node[@type='Other']/node[@type='Other']/node[@type='Other']/node[@type='Other']/node[@type='Other']/node[@type='Other']/node[@type='Other']/node[@type='Other']/node[@type='Table']/node[@type='Cell']/node[@type='Other']/node[@type='Other']/node[@type='ScrollView']/node[@type='Other' and @index=0]"

    // 使用自定义的 xpath() 方法获取元素
    let elements = xpath(xpathExpression);  // 假设它返回的是一个元素集合

    console.log(elements.getNodeInfo(10000))
    // if (elements) {
    //     let element = elements.index;// 获取第一个匹配的元素
    //
    //     console.log(element)
    //     // 执行点击操作
    //     try {
    //         await element.click;
    //         console.log("Element clicked!");
    //     } catch (error) {
    //         console.error("Error clicking the element:", error);
    //     }
    // } else {
    //     console.log("No matching elements found.");
    // }
}

//click_tanchuan() 購入手続きへ
function click_huobi() {
    setFetchNodeParam({
        "labelFilter": "2",
        "maxDepth": "70",
        "visibleFilter": "2",
        "excludedAttributes": "visible,2"
    })
    let node = name("円").getOneNodeInfo(10000)
    logd(JSON.stringify(node))
    if (node) {
        logd(node.clickRandom())
    }

}

function click_bluewhale() {
    setFetchNodeParam({
        "labelFilter": "2",
        "maxDepth": "70",
        "visibleFilter": "2",
        "excludedAttributes": "visible,2"
    })
    let node = name("bluewhale").getOneNodeInfo(10000)
    logd(JSON.stringify(node))
    if (node) {
        logd(node.clickRandom())
    }

}


//注册---------------------------------------------------------------------------------------
function rakuten_register() {
    rakuten_register_getdate();
    sleep(200);
    if (keyword != "" && lname_kana != "" && post != "" && acc_email != "" && acc_pass != "") {
        //一件新机
        new_iphone();
        sleep(500);
        //home();
        //打开乐天app
        open_rakuten()

        // 搜索产品点到产品页面
        reg_search()

        //产品页面 点击属性
        if (reg_attribute()) {
            return false
        }

        sleep(2000);

        //到达购物车页面
        reg_cart()

        //判断是否在登录页面
        sleep(1000);
        reg_sgin()

        //判断邮箱是否已被使用
        sleep(1000)
        sgincheck()

        // return false

        //判断//选支付方式
        sleep(1000)
        reg_payment()

        // 确认支付订单
        reg_confirmorder()

        //订单页面上传订单
        reg_getOrder()

        //订单页面返回购买记录页面进行登录
        reg_login()

        //刷单天关键词流量
        rakuten_key_view();

        //AMG 重命名
        new_iphone_new_name()
        sleep(1000);

        //关闭当前APP
        closeapp("jp.co.rakuten.ichiba")


    } else {
        logd("数据无");
    }
}

//注册结束---------------------------------------------------------------------------------------


//注册2---------------------------------------------------------------------------------------
function rakuten_register2() {
    rakuten_register_getdate();
    sleep(200);
    if (keyword != "" && lname_kana != "" && post != "" && acc_email != "" && acc_pass != "") {
        // //一件新机
        new_iphone();
        sleep(500);
        ////home();
        //打开乐天app
        var result = appLaunch("jp.co.rakuten.ichiba", "1");
        logd("打开乐天app 等待5秒");
        sleep(2000);

        //今はしない
        clickPoint(370, 1106);
        sleep(500);
        clickPoint(370, 1038);
        sleep(500);
        clickPoint(254, 92);
        sleep(500);
        input_keyword(keyword);
        logd("输入关键词: " + keyword);
        an_enter();
        sleep(2000);
        huadong();
        sleep(500);
        ////点击店铺名称
        let random_int = random(1, 5);
        ////随机滑动 点击店铺名称
        for (let s = 0; s < random_int; s++) {
            huadong();
            sleep(200);
        }
        sleep(2000);
        let random_shop = click_image_result("random_shop.png")
        if (random_shop == "yes") {
            sleep(4000);
        } else {
            sleep(3000);
            click_image_result("random_shop.png")
            sleep(4000);
        }

        // //产品页面 点击属性
        huadong();
        sleep(1000);
        huadong();
        sleep(1500);
        clickPoint(588, 1168);//加入购物车
        sleep(3000);

        for (var y = 0; y < 4; y++) {
            var cart_page = click_image_result("cp_page.png")
            if (cart_page == "yes") {
                logd("第次选中属性" + y);
                sleep(1000);
                click_image_result("ok.png");
                sleep(500);
                zhaotu_images_num("size1.png", y);
                sleep(1000);
                zhaotu_images_num("size1.png", y + 4);
                sleep(1000);
                click_image_result7("currency.png")
                sleep(500);

                var select_xiala = click_image_result7("select_xiala.png");
                if (select_xiala == "yes") {
                    sleep(500);
                    click_image_result7("select_xiala_values.png");
                    sleep(500);
                    click_image_result7("select_xiala.png");
                    sleep(500);
                    click_image_result7("select_xiala_values.png");
                    sleep(500);

                }
                var select_xiala = click_image_result7("radio_img.png")
                if (select_xiala == "yes") {
                    sleep(500);
                    click_image_result7("radio_img.png")
                    sleep(500);
                }

                var stock_img = pd_images_123("stock_img.png", 0.7, 0)
                if (stock_img == "yes") {
                    sleep(500)
                    //关闭当前APP
                    closeapp("jp.co.rakuten.ichiba")
                    sleep(1000)
                    continue;
                }

                //点击购物
                sleep(500);
                click_addcart()//加入购物车
                sleep(4000);
            }
        }
        sleep(2000);


        //判断是否在购物车页面
        // //到达购物车页面
        var cart_pageaa = pd_images_123("cart_page.png", 0.7, 0)
        if (cart_pageaa == "yes") {
            huadong();
            sleep(1000);
            clickPoint(362, 1134);//加入购物车

            sleep(2000);
        } else {
            //不在购物车直接退出，可能是属性问题选不到
            //关闭乐天app
            sleep(500)
            //关闭当前APP
            closeapp("jp.co.rakuten.ichiba")
            sleep(1000)
        }

        //判断是否在登录页面
        sleep(1000);
        var login_page = pd_images_123("passtext.png", 0.7, 0)
        if (login_page == "yes") {
            logd("在点击注册页面");
            huadong();
            sleep(900);
            click_image_result7("butt_rg.png")
            sleep(4000);

        } else {
            logd("不在点击注册页面");
        }


        //判断是注册提交信息页面
        var login_page = click_image_result("rg_info.png")
        if (login_page == "yes") {

            // var acc_keyword = "";
            // var acc_lname = "";
            // var acc_fname = "";
            // var acc_lname_kana = "";
            // var acc_fname_kana = "";
            // var acc_post = "";
            // var acc_address = "";
            // var acc_iphone_1 = "";
            // var acc_iphone_2 = "";
            // var acc_iphone_3 = "";
            // var acc_email = "";
            // var acc_pass = "";
            logd("在注册提交信息页面");
            click_image_result("acc_lname.png")
            sleep(300);
            input_keyword(lname);
            sleep(300);
            click_image_result("acc_fname.png")
            sleep(300);
            input_keyword(fname);
            sleep(300);
            click_image_result("acc_lname_kana.png")
            sleep(300);
            input_keyword(lname_kana);
            sleep(300);
            click_image_result("acc_fname_kana.png")
            sleep(300);
            input_keyword(fname_kana);
            sleep(500);
            click_image_result("acc_post.png")
            sleep(500);
            input_keyword(post);
            sleep(2000);
            input_keyword(address);
            sleep(500);
            click_image_result("address_lz.png")
            sleep(500);
            click_images_123("iphone1.png", 0.6, 0)
            sleep(700);
            input_keyword(iphone_1);
            sleep(300);
            an_tabl()
            sleep(200);
            input_keyword(iphone_2);
            sleep(300);
            an_tabl()
            sleep(200);
            input_keyword(iphone_3);
            sleep(500);
            click_image_result("iphone_a.png")
            sleep(500);
            click_image_result("acc_email.png")
            sleep(500);
            input_keyword(acc_email);
            sleep(300);
            click_image_result("acc_email_2.png")
            sleep(500);
            click_image_result("paisong.png")
            sleep(500);
            huadong();
            huadong();
            sleep(500);
            click_image_result("acc_pass.png")
            sleep(500);
            input_keyword(acc_pass);
            sleep(500);
            click_image_result("acc_pass2.png")
            sleep(1000);
            click_image_result("bank_next.png")
            sleep(3000);
        } else {
            logd("不在在登陆页面");
        }

        //判断//是否登录失败
        var email_pass_error = click_image_result("email_pass_error_rg.png")
        if (email_pass_error == "yes") {
            // logd("邮箱被注册错误: " + acc_email);
            // //回传提交数据
            // update_login_fail();
            // sleep(1000)
            acc_email = "a" + acc_email;
            logd("失败该邮箱重新注册");
            sleep(1000);
            huadong()
            huadong()
            sleep(1000);
            click_image_result("acc_email.png")
            sleep(500);
            click_image_result("acc_email.png")
            sleep(500);
            input_keyword("a");
            sleep(500);
            click_image_result("paisong.png")
            sleep(500);
            huadong()
            huadong()
            sleep(500);
            click_image_result("acc_pass.png")
            sleep(500);
            input_keyword(acc_pass);
            sleep(500);
            click_image_result("acc_pass2.png")
            sleep(1000);
            click_image_result("bank_next.png")
            sleep(4000);
            var pay_page = click_image_result("bank.png")
            if (pay_page == "yes") {
                sleep(1000)
            } else {
                sleep(2000)
            }
        }

        //判断//选支付方式
        sleep(1000)
        var pay_page = click_image_result("bank.png")
        if (pay_page == "yes") {
            logd("在选支付页面");
            sleep(200);
            var randomnumber = random(1, 4);
            if (randomnumber == 1) {
                huadong()
                click_image("711_luosheng.png")
                sleep(200);
                click_image("711-ok.png")
                sleep(200);
                huadong()
            } else if (randomnumber == 2) {
                huadong()
                click_image("711_luosheng.png")
                sleep(200);
                click_image("luosheng-ok.png")
                sleep(200);
                huadong()
            } else if (randomnumber == 3) {
                click_image_result("bank.png")
                sleep(200);
                huadong()
                sleep(200);
            } else if (randomnumber == 4) {
                click_image_result("bank.png")
                sleep(200);
                huadong()
                sleep(200);
            }

            sleep(200);
            click_image("bank_next.png")
            sleep(3000)
        } else {
            logd("不在在选中支付页面");
        }

        //判断//确认支付
        var conf_page = click_image_result("order_conf.png")
        if (conf_page == "yes") {
            logd("在确认支付页面");
            sleep(1000)
            huadong_big()
            huadong_big()
            huadong_big()
            huadong_big()
            huadong_big()
            click_image("button_pay_confirm.png")
            sleep(3000)
        } else {
            logd("不在确认支付页面");
        }


        //判断//获取订单号
        var order_page = click_image_result("order_bq.png")
        if (order_page == "yes") {

            //判断//获取订单号
            sleep(1000)
            var ads1_page = click_image_result("disp_ads.png")
            if (ads1_page == "yes") {
                click_image_result("disp_ads.png")
                sleep(1000)
                click_image_result("guangbi.png")
                sleep(1000)
            }

            //判断//获取订单号
            sleep(1000)
            var ads1_page = click_image_result("disp_ads1.png")
            if (ads1_page == "yes") {
                click_image_result("disp_ads1.png")
                sleep(1000)
                click_image_result("guangbi.png")
                sleep(1000)
            }

            click_tanchuan()
            logd("点击首页今はしない");
            logd("在订单页面");
            sleep(500)
            var orderid = get_text()
            logd(orderid);
            acc_order = orderid;
            //回传 记录邮箱和设备id使用
            rg_updateemail_static()
            sleep(500)


        } else {
            logd("不在订单页面");
        }


        ////登录账户
        var buttlogin = click_image_result("order_bq.png")
        if (buttlogin == "yes") {
            logd("订单页面，来关闭");
            sleep(500);
            click_image_result("guangbi.png")
            sleep(1000);
            click_image_result("history_order.png")
            sleep(500);
            click_image_result("buttlogin.png")
            sleep(500);
            click_image_result("login_email_2.png")
            sleep(500);
            input_keyword(acc_email);
            sleep(500);
            click_image_result("login_pass_2.png")
            sleep(500);
            input_keyword(acc_pass);
            sleep(1000);
            click_image_result("buttlogin.png")
            sleep(3000);

            new_iphone_new_name()
            sleep(1000);

        } else {
            logd("历史登陆页面");
        }
        //关闭当前APP
        closeapp("jp.co.rakuten.ichiba")

    } else {
        logd("数据无");
    }
}


function zhaotu_images_num(imaname, y) {
    //从工程目录下res文件夹下读取sms.png文件
    let sms = readResAutoImage(imaname);
    //抓取屏幕
    let aimage = image.captureFullScreen();
    // logd("aimage " + imaname);
    if (aimage != null) {
        //在图片中查找
        let points = image.findImage(aimage, sms, 0, 0, 0, 0, 0.8, 0.8, y, 5);
        logd(JSON.stringify(points));
        //这玩意是个数组
        if (points && points.length > 0) {

            if (y == 0) {
                y == y
            } else {
                y == y - 1
            }
            for (let i = y; i < points.length; i++) {
                logd(points[i])
                let x = parseInt((points[i].left + points[i].right) / 2)
                let y = parseInt((points[i].top + points[i].bottom) / 2)
                //点击坐标
                sleep(500);
                clickPoint(x, y)
                sleep(1000);
                return "yes";
            }
        } else {
            return "no";
        }
        //图片要回收
        image.recycle(aimage)
    }
    //图片要回收
    image.recycle(sms)

    sleep(500);
}

//获取数据
function rakuten_register_getdate() {
    var url = "https://gz2.erp2018.top/wjorder/api/mobile/select2_json.php?account_type=rakuten&rg_fs=iphone";
    var x = http.httpGet(url, "", 90 * 1000, {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4796.0 Safari/537.36"});

    let arr = x.split("|");
    keyword = arr[0];
    lname = arr[1];
    fname = arr[2];
    lname_kana = arr[3];
    fname_kana = arr[4];
    post = arr[5];
    address = arr[6];
    iphone_1 = arr[7];
    iphone_2 = arr[8];
    iphone_3 = arr[9];
    acc_year = arr[10];
    acc_yue = arr[11];
    acc_day = arr[12];
    acc_email = arr[13];
    acc_pass = arr[14];
    acc_id = arr[15];

    logd(x);
}


//获取数据
function rakuten_getdate_day_keyword_view() {
    var url = "https://rakuten.erp2018.top/rakuten_getdate_day_keyword_view.php";
    var x = http.httpGet(url, "", 90 * 1000, {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4796.0 Safari/537.36"});
    if (x != "") {
        keyword = x;
    }
    logd(x);
}

//获取数据
function getdate_rpp() {
    var url = "https://gz2.erp2018.top/wjorder/api/mobile/select2_json.php?account_type=rakuten&rg_fs=iphone";
    var x = http.httpGet(url, "", 90 * 1000, {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4796.0 Safari/537.36"});

    let arr = x.split("|");
    keyword = arr[0];
    lname = arr[1];
    fname = arr[2];
    lname_kana = arr[3];
    fname_kana = arr[4];
    post = arr[5];
    address = arr[6];
    iphone_1 = arr[7];
    iphone_2 = arr[8];
    iphone_3 = arr[9];
    acc_email = arr[10];
    acc_pass = arr[11];

    logd(x);
}

//获取数据
function getdate_login_rg() {
    var iphoneid = device.getDeviceId();
    var url = "https://rakuten.erp2018.top/iphone_configuration.php?iphoneid=" + iphoneid;
    var x = http.httpGet(url, "", 90 * 1000, {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4796.0 Safari/537.36"});
    return x
}

// 注册的步骤----------------------------------------------------------------------------------------

//注册的搜索产品
function reg_search() {
    laoleng.EC.initNode()
    sleep(500)
    if (findNode(name("キーワード検索").label("キーワード検索").type("SearchField"), true)) {
        //1.点击首页搜索框框
        logd("搜索产品点到产品页面");
        sleep(1500);
        //2.输入关键词
        input_keyword(keyword);
        logd("输入关键词: " + keyword);
        //回车
        an_enter();
        sleep(4000);
        huadong();
        sleep(500);
        ////点击店铺名称
        var random_int = random(1, 5);
        ////随机滑动 点击店铺名称
        for (var s = 0; s < random_int; s++) {
            huadong();
            sleep(200);
        }
        sleep(2000);
        if (findNode(label("Icon.Item.ShopIcon").type("Image").accessible(true).visible(true), true)) {
            sleep(3000);
        } else {
            sleep(3000);
            findNode(label("Icon.Item.ShopIcon").type("Image").accessible(true).visible(true), true)
            sleep(3000);
        }
    } else {
        logd("登录失败");
    }
}

//注册的属性选择
function reg_attribute() {
    laoleng.EC.initNode()
    // let RakutenFashion =
    if (findNode(name("楽天ブックス").type("Link")) || findNode(name("Rakuten Fashion").type("Link"))) {
        console.log('官方店铺')
        sleep(100)
        return true
    } else if (findNode(name("商品詳細").type("StaticText"))) {
        huadong();
        sleep(800);
        huadong();
        sleep(1000);
        logd("点购物 在产品页面");
        let addincart = click_addcart()
        if (addincart != "null") {
            sleep(4000)
            let shopdetail = name("商品詳細を選択").type("StaticText").getOneNodeInfo(10000)
            if (shopdetail) {
                logd('这是商品详细选择页面')
                huadong250()
                sleep(2000)
                if (findNode(name("商品詳細").type("TextView"))) {
                    logd('有商品属性')
                    //获得 未選択 的个数
                    let unselected = label("未選択").type("StaticText").getNodeInfo(10000)

                    //这是商品属性
                    if (unselected) {
                        for (let i = 0; i < unselected.length; i++) {
                            //获得各个 未選択 下面的选择器
                            let attrs = nameMatch("VariantSelectorView_.*.ScrollView").type("ScrollView").getNodeInfo(10000)
                            if (attrs) {
                                //选择器下的Other
                                let attr = attrs[i].child(0).allChildren()
                                attr[random(0, attr.length - 1)].clickCenter()
                                sleep(500)
                            }
                        }

                        sleep(2000)
                        huadong()
                        sleep(1500)
                    }

                    //有 (必須) 才进入点击
                    let req = valueMatch(".*(必須)").type("TextView").getNodeInfo(10000)
                    if (req) {
                        //这是必须要选
                        let dom = name("選択してください").type("Button").getNodeInfo(10000)
                        if (dom) {
                            for (let i = 0; i < dom.length; i++) {
                                sleep(500)
                                dom[i].clickCenter()
                                sleep(500)

                                let havetab = type("Cell").depth('7').getNodeInfo(10000)
                                if (havetab) {
                                    let rod = random(1, havetab.length)
                                    let clickCell = findNode(type("Cell").depth('7').index(rod), true)
                                    if (!clickCell) {
                                        logd('点击选项失败' + rod)
                                        sleep(500)
                                    }
                                }
                            }

                            sleep(1000)
                            huadong()
                            sleep(4100)
                        }

                        laoleng.EC.initNode()
                        if (findNode(name("了解した").type("StaticText"), true)) {
                            sleep(1000)
                        } else {
                            logd("没有点击没有句号的了解")

                            sleep(500)
                        }
                        sleep(4000)
                        laoleng.EC.initNode()
                        let lastop = name("了解した。").value("了解した。").type("StaticText").getOneNodeInfo(10000)
                        if (lastop) {
                            lastop.clickCenter()
                            sleep(500)
                        } else {
                            logd("没有点击有句号的了解")
                        }
                        sleep(300)
                        //点击购物
                        click_addcart()//加入购物车
                        sleep(1500)

                        laoleng.EC.initNode()
                        if (findNode(label("売り切れの商品は購入できません").type("StaticText"))) {
                            console.log('选的商品无库存')
                            return true
                        } else if (findNode(label("OK").type("Button").depth(11).index(0), true)) {
                            sleep(500)
                            logd('点击了ok按钮')
                            sleep(500)
                            //这是必须要选
                            let dom = name("選択してください").type("Button").getNodeInfo(10000)
                            if (dom) {
                                for (let i = 0; i < dom.length; i++) {
                                    sleep(500)
                                    dom[i].clickCenter()
                                    sleep(500)

                                    let havetab = type("Cell").depth('7').getNodeInfo(10000)
                                    if (havetab) {
                                        let rod = random(1, havetab.length)
                                        let clickCell = findNode(type("Cell").depth('7').index(rod), true)
                                        if (!clickCell) {
                                            logd('点击选项失败' + rod)
                                            sleep(500)
                                        }
                                    }
                                }

                                sleep(1000)
                                huadong()
                                sleep(4100)
                            }
                            laoleng.EC.initNode()
                            if (findNode(name("了解した").type("StaticText"), true)) {
                                sleep(1500)
                            } else {
                                logd("没有点击没有句号的了解")
                            }
                            sleep(3800)
                            laoleng.EC.initNode()
                            let lastop = name("了解した。").value("了解した。").getOneNodeInfo(10000)
                            if (lastop) {
                                lastop.clickCenter()
                                sleep(300)
                            } else {
                                logd("没有点击有句号的了解")
                            }
                            sleep(500)
                            //点击购物
                            click_addcart()//加入购物车
                            sleep(4000)
                        } else {
                            sleep(4000)
                        }
                        if (findNode(label("現在売り切れの商品です").name("現在売り切れの商品です").type("StaticText"))) {
                            console.log('暂无库存')
                            return true
                        }

                    } else {
                        sleep(500)
                        //点击购物
                        click_addcart()//加入购物车
                        laoleng.EC.initNode()
                        if (findNode(label("売り切れの商品は購入できません").type("StaticText"))) {
                            console.log('选的商品无库存')
                            return true
                        }
                        if (findNode(label("現在売り切れの商品です").name("現在売り切れの商品です").type("StaticText"))) {
                            console.log('暂无库存')
                            return true
                        }
                        sleep(4000)
                    }
                } else {    //若是没有属性，而有较少的选项式那点击ok后会有重新进行选择
                    //有 (必須) 才进入点击
                    let req = valueMatch(".*(必須)").type("TextView").getNodeInfo(10000)
                    if (req) {
                        //这是必须要选
                        let dom = name("選択してください").type("Button").getNodeInfo(10000)
                        if (dom) {
                            for (let i = 0; i < dom.length; i++) {
                                sleep(500)
                                dom[i].clickCenter()
                                sleep(500)

                                let havetab = type("Cell").depth('7').getNodeInfo(10000)
                                if (havetab) {
                                    let rod = random(1, havetab.length)
                                    let clickCell = findNode(type("Cell").depth('7').index(rod), true)
                                    if (!clickCell) {
                                        logd('点击选项失败' + rod)
                                        sleep(500)
                                    }
                                }
                            }

                            sleep(1000)
                            huadong()
                            sleep(3800)
                        }

                        laoleng.EC.initNode()
                        if (findNode(name("了解した").type("StaticText"), true)) {
                            sleep(800)
                        } else {
                            logd("没有点击没有句号的了解")
                        }

                        sleep(3800)
                        laoleng.EC.initNode()
                        let lastop = name("了解した。").value("了解した。").accessible(true).getOneNodeInfo(10000)
                        if (lastop) {
                            lastop.clickRandom()
                            sleep(200)
                        } else {
                            logd("没有点击有句号的了解")
                        }
                        sleep(500)
                        //点击购物
                        click_addcart()//加入购物车
                        sleep(1500)
                        laoleng.EC.initNode()
                        if (findNode(label("売り切れの商品は購入できません").type("StaticText"))) {
                            console.log('选的商品无库存')
                            return true
                        } else if (findNode(label("OK").type("Button").depth(11).index(0), true)) {
                            sleep(500)
                            logd('点击了ok按钮')
                            sleep(500)
                            //这是必须要选
                            let dom = name("選択してください").type("Button").getNodeInfo(10000)
                            if (dom) {
                                for (let i = 0; i < dom.length; i++) {
                                    sleep(500)
                                    dom[i].clickCenter()
                                    sleep(500)

                                    let havetab = type("Cell").depth('7').getNodeInfo(10000)
                                    if (havetab) {
                                        let rod = random(1, havetab.length)
                                        let clickCell = findNode(type("Cell").depth('7').index(rod), true)
                                        if (!clickCell) {
                                            logd('点击选项失败' + rod)
                                            sleep(500)
                                        }
                                    }
                                }

                                sleep(1000)
                                huadong()
                                sleep(4100)
                            }
                            laoleng.EC.initNode()
                            if (findNode(name("了解した").type("StaticText"), true)) {
                                sleep(1500)
                            } else {
                                logd("没有点击没有句号的了解")
                            }
                            sleep(3800)
                            laoleng.EC.initNode()
                            let lastop = name("了解した。").value("了解した。").getOneNodeInfo(10000)
                            if (lastop) {
                                lastop.clickCenter()
                                sleep(300)
                            } else {
                                logd("没有点击有句号的了解")
                            }
                            sleep(500)
                            //点击购物
                            click_addcart()//加入购物车
                            sleep(4000)
                        } else {
                            sleep(4000)
                        }
                        sleep(100)
                        if (findNode(label("現在売り切れの商品です").name("現在売り切れの商品です").type("StaticText"))) {
                            console.log('暂无库存')
                            return true
                        }

                    } else {
                        sleep(500)
                        //点击购物
                        click_addcart()//加入购物车
                        if (findNode(label("現在売り切れの商品です").name("現在売り切れの商品です").type("StaticText"))) {
                            console.log('暂无库存')
                            return true
                        }
                        sleep(4000)
                    }
                }
            } else {
                logd('该商品没有属性，跳过属性选择')
                sleep(300)
            }

        } else {
            logd("没有找到添加购物车按钮");
        }
        sleep(2000)
        // click_addcart()//加入购物车
    } else {
        logd("不在产品页面")
        return true
    }
}

//注册购物车页面
function reg_cart() {
    sleep(500)
    laoleng.EC.initNode()
    let incart = name("買い物かご").type("Other").getOneNodeInfo(10000)
    if (incart) {
        //到达购物车页面
        if (findNode(label("削除する").type("Link").index(0))) {
            sleep(2000)
            huadong();
            sleep(4200)
            laoleng.EC.initNode()
            if (findNode(name("購入手続き").label("購入手続き").type("Button"), true)) {
                sleep(2000);
            }
            sleep(2000)
        } else {
            logd('还没完全加载购物车页面')
        }
    } else {
        logd('未进入购物车结算页面')
    }
}

//注册的输入密码页面
function reg_sgin() {
    laoleng.EC.initNode()
    // setFetchNodeParam({
    //     "labelFilter": "1",
    //     "maxDepth": "60",
    //     "visibleFilter": "1",
    //     "excludedAttributes": ""
    // })
    sleep(800)
    //密码页面
    if (findNode(value("パスワード").type("SecureTextField"))) {
        logd('在输入密码界面')
        huadong();
        sleep(1500);
        findNode(label("会員登録されていない方はこちら").name("会員登録されていない方はこちら").type("Button"), true)
        sleep(1200);
        laoleng.EC.initNode()
        if (findNode(label("注文者情報を入力").name("注文者情報を入力").type("StaticText"))) {
            logd("在注册提交信息页面");
            findNode(value("姓").type("TextField"), true)
            sleep(200);
            input_keyword(lname);
            // sleep(200);
            findNode(value("名").type("TextField"), true)
            sleep(200);
            input_keyword(fname);
            // sleep(200);
            findNode(value("セイ").type("TextField"), true)
            sleep(200);
            input_keyword(lname_kana);
            // sleep(200);
            findNode(value("メイ").type("TextField"), true)
            sleep(200);
            input_keyword(fname_kana);
            sleep(800);
            // an_tabl()
            if (findNode(label("郵便番号").type("StaticText"))) {
                let inputpwd = g_ret.parent().nextSiblings()[0]
                if (inputpwd) {
                    inputpwd.clickCenter()
                } else {
                    console.log('没有找到地址编码的节点')
                }
            } else {
                console.log('没有找到地址编码上方的文字节点')
            }
            sleep(500);
            input_keyword(post);
            sleep(3000);
            input_keyword(address);
            sleep(500);
            findNode(label("電話番号").type("StaticText"), true)
            sleep(500);
            findNode(value("000").type("TextField"), true)
            sleep(700);
            input_keyword(iphone_1);
            sleep(500);
            an_tabl()
            sleep(400);
            input_keyword(iphone_2);
            sleep(500);
            an_tabl()
            sleep(400);
            input_keyword(iphone_3);
            sleep(300);
            findNode(label("電話番号").type("StaticText").depth(24), true)
            sleep(300);
            findNode(value("rakuten@rakuten.com").type("TextField"), true)
            sleep(300);
            input_keyword(acc_email);
            sleep(300);
            findNode(label("メールアドレス").name("メールアドレス").type("StaticText"), true)
            sleep(500);
            findNode(label("上記の住所に送る").name("上記の住所に送る").type("StaticText"), true)
            sleep(500);
            huadong();
            huadong();
            sleep(2000);
            if (findNode(label("パスワード").type("StaticText"))) {
                let inputpwd = g_ret.parent().nextSiblings()[0]
                if (inputpwd) {
                    inputpwd.clickCenter()
                } else {
                    console.log('没有找到密码的节点')
                }
            } else {
                console.log('没有找到密码上方的文字节点')
            }
            sleep(500);
            input_keyword(acc_pass);
            sleep(500);
            findNode(label("パスワード").type("StaticText"), true)
            sleep(1000);
            findNode(label("次へ").name("次へ").type("Button"), true)
            sleep(3000);
        } else {
            logd("不在注册页面");
        }
    } else {
        logd("不在输入密码界面");
    }
}

//判断注册是是否报错
function sgincheck() {
    laoleng.EC.initNode()
    if (findNode(label("エラー").name("エラー").type("StaticText"))) {
        logd("邮箱被注册错误: " + acc_email);
        //回传提交数据
        rg_updateemail_static()
        sleep(1000)
        // let afteremail = acc_email
        // let lowletter = getlowletter()
        // console.log(lowletter)
        // acc_email = lowletter + acc_email;
        // logd("注册失败，该邮箱重新注册");
        // sleep(1000);
        // huadong()
        // huadong()
        // sleep(1000);
        // if (findNode(label("メールアドレス").type("StaticText"))) {
        //     let inputem = g_ret.parent().nextSiblings()[0]
        //     if (inputem) {
        //         cleft(inputem.bounds)
        //         sleep(500);
        //         input_keyword(lowletter);
        //     } else {
        //         let inputemail = value(afteremail).type("TextField").index(0).getOneNodeInfo(10000)
        //         cleft(inputemail && inputemail.bounds)
        //         sleep(500);
        //         input_keyword(lowletter);
        //     }
        // }
        // sleep(500);
        // findNode(label("上記の住所に送る").name("上記の住所に送る").type("StaticText"), true)
        // sleep(500);
        // huadong()
        // huadong()
        // sleep(1500);
        // if (findNode(label("パスワード").type("StaticText"))) {
        //     let inputpwd = g_ret.parent().nextSiblings()[0]
        //     if (inputpwd) {
        //         inputpwd.clickCenter()
        //     } else {
        //         console.log('没有找到密码的文字节点')
        //     }
        // } else {
        //     console.log('没有找到密码的节点')
        // }
        // sleep(500);
        // input_keyword(acc_pass);
        // sleep(500);
        // findNode(label("パスワード").type("StaticText"), true)
        // sleep(1000);
        // findNode(label("次へ").name("次へ").type("Button"), true)
        // sleep(4000);
    }
}

//注册的选择支付方式

function reg_payment() {
    //新
    laoleng.EC.initNode()
    if (findNode(name("支払い方法の選択").type("Other"))) {
        logd("在选支付页面");
        sleep(200);
        var randnum = random(1, 4)
        if (randnum === 1) {
            huadong()
            let ofother = findNode(name("コンビ二・郵便局等").type("StaticText"), true)
            if (!ofother) {
                logd('点击郵便局失败')
            }
            sleep(200);
            let firstch = findNode(name("セブンイレブン（前払）").type("StaticText"), true)
            if (!firstch) {
                logd('点击郵便局第一个选项失败')
            }
            sleep(200);
            huadong()
        } else if (randnum === 2) {
            huadong()
            let ofother = findNode(name("コンビ二・郵便局等").type("StaticText"), true)
            if (!ofother) {
                logd('点击郵便局失败')
            }
            sleep(200);
            let secondch = findNode(name("ローソン、郵便局ATM等（前払）").type("StaticText"), true)
            if (!secondch) {
                logd('点击郵便局第二个选项失败')
            }
            sleep(200);
            huadong()
        } else if (randnum === 3) {
            let clickbank = findNode(name("銀行振込").type("StaticText"), true)
            if (!clickbank) {
                logd('点击bank支付失败')
            }
            sleep(200);
            huadong()
            sleep(200);
        } else if (randnum === 4) {
            let clickbank = findNode(name("銀行振込").type("StaticText"), true)
            if (!clickbank) {
                logd('点击bank支付失败')
            }
            sleep(200);
            huadong()
            sleep(200);
        }
        huadong()
        sleep(500);
        if (findNode(name("次へ").type("Button"), true)) {
            sleep(1000)
        } else {
            logd('点击确认支付按钮失败')
        }
        sleep(4000)
    } else {
        logd("不在在选中支付页面");
    }
}

//注册的确认订单页面
function reg_confirmorder() {
    laoleng.EC.initNode()
    if (findNode(name("注文内容の確認").type("StaticText"))) {
        logd("在确认支付页面");
        huadong()
        sleep(1500)
        if (findNode(name("注文を確定する").type("Button"), true)) {
            logd('第一次点击支付成功')
            sleep(4000)
        } else {
            logd('第一次点击支付失败')
            huadong_big()
            huadong_big()
            huadong_big()
            huadong_big()
            if (findNode(name("注文を確定する").type("Button"), true)) {
                sleep(4000)
            } else {
                logd('第二次点击支付失败')
            }
        }
    } else {
        logd("不在确认支付页面");
    }
}

//注册的订单上传页面
function reg_getOrder() {
    sleep(1000)
    click_tanchuan()
    logd("点击last今はしない")
    sleep(500)
    if (findNode(name("注文内容がショップに送信されました。"))) {
        closed()
        logd("在订单结束页面")
        //今はしない
        sleep(500)
        click_tanchuan()
        logd("点击last今はしない")
        sleep(500)
        acc_order = get_text()
        if (acc_order) {
            logd(acc_order);
            //回传 记录邮箱使用
            rg_updateemail_static()
            sleep(500)
        } else {
            sleep(2000)
            utfind(name("今はしない"), 1000, true, 8)
            acc_order = get_text()
            logd(acc_order);

            //回传 记录邮箱使用
            rg_updateemail_static()
            sleep(500)
        }
    } else {
        logd("不在订单结束页面")
    }
}

//注册的登录页面
function reg_login() {


    closed()
    //今はしない
    click_tanchuan()
    laoleng.EC.initNode()

    if (findNode(labelMatch("注文番号.*").type("StaticText").visible(true).index(0))) {
        //今はしない
        click_tanchuan()
        logd("订单页面，点关闭去登录")
        sleep(500)
        findNode(label("Close").name("Close").type("Button"), true)
        sleep(1000);
        findNode(label("購入履歴").name("ai.purchaseHistory").type("Button"), true)
        sleep(500);
        findNode(label("ログイン").name("ログイン").type("Button"), true)
        sleep(500);
        findNode(label("ユーザIDを入力してください").name("ユーザIDを入力してください").type("TextField"), true)
        sleep(500);
        input_keyword(acc_email);
        sleep(500);
        findNode(label("パスワードを入力してください").name("パスワードを入力してください").type("SecureTextField"), true)
        sleep(500);
        input_keyword(acc_pass);
        sleep(1000);
        findNode(label("ログイン").name("ログイン").type("Button"), true)
        sleep(1000);


        //直接回传
        rg_updateemail_static()
        sleep(2000);


    } else {
        logd("不在历史登陆页面");
    }

}

// 注册的步骤结束----------------------------------------------------------------------------------------

//获取数据gmail
function getdate_rg_gmail() {
    var url = "https://gmail.sanzhongai.com/mailbox_list_api.php";
    var x = http.httpGet(url, "", 90 * 1000, {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4796.0 Safari/537.36"});

    console.log(x)
    let arr = x.split("|");
    acc_id = arr[0];
    acc_email_fuzhu = arr[2];

    let arrname = arr[1].split(" ");
    lname = arrname[0];
    fname = arrname[1];

    logd(url + " " + acc_id + " " + lname + " " + fname + " " + acc_email_fuzhu + " " + x);
}

//SMS 获取电话 取消
function getsms_activate_quxiao() {
    var url = "https://api.sms-activate.ae/stubs/handler_api.php?api_key=f117A0f47e344beAf51d202d7395bAf9&action=setStatus&status=8&id=" + acc_iphone_id;
    var x = http.httpGet(url, "", 90 * 1000, {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4796.0 Safari/537.36"});

    logd(x);

}

//SMS 获取电话
function getsms_activate() {
    var url = "https://api.sms-activate.guru/stubs/handler_api.php?api_key=f117A0f47e344beAf51d202d7395bAf9&action=getNumber&service=go&country=31";
    var x = http.httpGet(url, "", 90 * 1000, {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4796.0 Safari/537.36"});

    let arr = x.split(":");
    acc_iphone_static = arr[0];
    acc_iphone_id = arr[1];
    acc_iphone_all = "+" + arr[2];
    logd(url + " " + acc_iphone_static + " " + acc_iphone_id + " " + " " + acc_iphone_all + " " + x);
    //保存电话
    getsms_activate_huichuan()
}

//SMS 获取电话回传//注册信息
function getsms_activate_huichuan() {
    rg_date = new Date().Format("yyyy-MM-dd")
    let url = "https://rakuten.erp2018.top/wj_facebook_register_gmail.php";
    let pa = {
        "acc_id": acc_id,
        "iphonenum": acc_iphone_static + ":" + acc_iphone_id + ":" + acc_iphone_all,
        "gmail": acc_email + "----" + acc_pass,
        "rg_date": rg_date
    };
    let x = http.httpPost(url, pa, null, 90 * 1000, {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4796.0 Safari/537.36"});
    logd(url + x);

}

//SMS 获取电话回传//注册信息
function getsms_activate_huichuan2() {
    rg_date = new Date().Format("yyyy-MM-dd")
    let url = "https://rakuten.erp2018.top/wj_facebook_register_gmail.php";
    let pa = {
        "acc_id": acc_id,
        "gmail": acc_email + "-----" + acc_pass + "----" + acc_email_fuzhu + "----" + acc_year + "-" + acc_yue + "-" + acc_day,
        "static": "1"
    };
    let x = http.httpPost(url, pa, null, 90 * 1000, {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4796.0 Safari/537.36"});
    logd(url + x);

}

//SMS 获取电话 验证码
function getsms_activate_yzm() {
    sleep(30000);
    var url = "https://api.sms-activate.guru/stubs/handler_api.php?api_key=f117A0f47e344beAf51d202d7395bAf9&action&action=getStatusV2&id=" + acc_iphone_id;
    var x = http.httpGet(url, "", 90 * 1000, {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4796.0 Safari/537.36"});

    //第一次获取验证码
    if (x.indexOf("G-") !== -1) {
        acc_iphone_yzm = x;
    } else {
        //第二次获取验证码
        logd("无法获取验证码-等待1分钟");
        sleep(30000);
        var url = "https://api.sms-activate.guru/stubs/handler_api.php?api_key=f117A0f47e344beAf51d202d7395bAf9&action&action=getStatusV2&id=" + acc_iphone_id;
        var x = http.httpGet(url, "", 90 * 1000, {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4796.0 Safari/537.36"});

        if (x.indexOf("G-") !== -1) {
            acc_iphone_yzm = x;
        }
    }

    if (x.indexOf("G-") !== -1) {
        acc_iphone_yzm = x;
        let arr = acc_iphone_yzm.split("G-");
        acc_iphone_yzm = arr[1];
        acc_iphone_yzm = acc_iphone_yzm.split(" ")[0];
    } else {
        acc_iphone_yzm = "no";
    }

    logd(url + " " + acc_iphone_yzm + " " + x);
    return acc_iphone_yzm;
}

function click_image_result_laolen5(imagesname) {
    while (true) {
        sleep(10)
        if (!keepScreen()) {
            continue
        }
        //只填图片名
        if (findImageByColorAll(imagesname)) {
            logd("1:" + JSON.stringify(gPointAll))
            for (let i = 0; i < gPointAll.length; i++) {
                logd(gPointAll[i].x, gPointAll[i].y)
                clickPoint(gPointAll[i].x, gPointAll[i].y)
                sleep(500)
            }

        }
    }
}

//-------------注册gmail方法---------------------------------------

//点击登录
function logingmail() {
    laoleng.EC.initNode()
    if (findNode(label("ログイン").type("Button"), true)) {
        sleep(500);
        if (findNode(label("Google").type("StaticText"), true)) {
            sleep(2000);
        }
    }
}

//-------------注册gmail方法结束---------------------------------------


//-------------注册gmail---------------------------------------
function gmail_register() {
    getdate_rg_gmail();
    acc_year = generate_year()
    acc_yue = generate_yue()
    acc_day = generate_day()
    acc_sex = randomsex()
    acc_pass = generatePassword(10)
    logd(acc_sex);
    sleep(200);

    if (acc_id != "" && lname != "" && fname != "") {
        // //一件新机
        new_iphone();
        sleep(500);
        ////home();
        //打开乐天app
        var result = appLaunch("com.google.Gmail", "1");
        logd("打开Gmailapp 等待5秒");
        sleep(2000);

        //今はしない
        var gmail_login = click_image_result("gmail_login.png")
        if (gmail_login == "yes") {
            sleep(500);
            var gmail_login_page2 = click_image_result("gmail_login_page2.png")
            if (gmail_login_page2 == "yes") {
                sleep(2000);
                var gmail_login_page3 = click_image_result("gmail_login_page3.png")
                if (gmail_login_page3 == "yes") {
                    sleep(4000);
                    click_image_result("gmail_rg1.png")
                    sleep(500);
                    click_image_result("gmail_rg2.png")
                    sleep(3000);
                    click_image_result("gmail_lname.png")
                    sleep(500);
                    input_keyword(lname);
                    sleep(500);
                    click_image_result("gmail_fname.png")
                    sleep(500);
                    input_keyword(fname);
                    sleep(500);
                    var gmail_chi = click_image_result("gmail_chi.png")
                    if (gmail_chi == "yes") {
                        sleep(3000);
                        click_image_result("gmail_yuer.png")
                        sleep(500);
                        input_keyword(acc_year);
                        sleep(500);
                        click_image_result("gmail_jbqb.png")
                        sleep(500);
                        //月份
                        var gmail_yue = click_image_result("gmail_yue.png")
                        if (gmail_yue == "yes") {
                            sleep(500);
                            if (acc_yue == "01") {
                                click_image_result("gmail_yue1.png")
                            }
                            if (acc_yue == "02") {
                                click_image_result("gmail_yue2.png")
                            }
                            if (acc_yue == "03") {
                                click_image_result("gmail_yue3.png")
                            }
                            if (acc_yue == "04") {
                                click_image_result("gmail_yue4.png")
                            }
                            if (acc_yue == "05") {
                                click_image_result("gmail_yue5.png")
                            }
                            if (acc_yue == "06") {
                                click_image_result("gmail_yue6.png")
                            }
                            if (acc_yue == "07") {
                                click_image_result("gmail_yue7.png")
                            }
                            if (acc_yue == "08") {
                                click_image_result("gmail_yue8.png")
                            }
                            if (acc_yue == "09") {
                                click_image_result("gmail_yue8.png")
                                acc_yue = "08";
                            }
                            if (acc_yue == "10") {
                                click_image_result("gmail_yue8.png")
                                acc_yue = "08";
                            }
                            if (acc_yue == "11") {
                                click_image_result("gmail_yue8.png")
                                acc_yue = "08";
                            }
                            if (acc_yue == "12") {
                                click_image_result("gmail_yue8.png")
                                acc_yue = "08";
                            }
                        }

                        //输入天
                        click_image_result("gmail_jbqb.png")
                        sleep(500)
                        click_image_result("gmail_day.png")
                        sleep(500);
                        input_keyword(acc_day);
                        sleep(500)
                        click_image_result("gmail_jbqb.png")
                        sleep(1000)


                        //性别
                        var gmail_sex = click_image_result("gmail_sex.png")
                        if (gmail_sex == "yes") {
                            sleep(1000);
                            if (acc_sex == "male") {
                                click_image_result("gmail_men.png")
                            }
                            if (acc_sex == "female") {
                                click_image_result("gmail_women.png")
                            }
                            sleep(500);
                        }

                        var gmail_chi = click_image_result("gmail_chi.png")
                        if (gmail_chi == "yes") {
                            sleep(5000);
                        }

                        //选中邮箱，输入密码
                        var gmail_email_xuanzhe_page = click_image_result("gmail_email_xuanzhe_page.png")
                        if (gmail_email_xuanzhe_page == "yes") {
                            sleep(1000);
                            var gettxt_email = laolen_gettxt_email()
                            if (gettxt_email.includes("@gmail.com")) {
                                clickPoint(72, 712);
                                sleep(1000);
                                click_image_result("gmail_chi.png")
                                sleep(5000);

                                //输入密码
                                var gmail_pass = click_image_result("gmail_pass.png")
                                if (gmail_pass == "yes") {
                                    sleep(500);
                                    input_keyword(acc_pass);
                                    sleep(500)
                                    laoleng.keys.enter()
                                    sleep(6000);

                                    //输入电话
                                    var gmail_iphone_page_a = click_image_result("gmail_iphone_page_a.png")
                                    if (gmail_iphone_page_a == "yes") {

                                        getsms_activate()
                                        //到达填写手机页面，填写电话
                                        var gmail_iphone_shuru = click_image_result("gmail_iphone_shuru.png")
                                        if (gmail_iphone_shuru == "yes") {
                                            sleep(500);
                                            input_keyword(acc_iphone_all);
                                            sleep(500)
                                            laoleng.keys.enter()
                                            sleep(500);
                                            click_image_result("gmail_chi.png")
                                            sleep(5000);
                                        }
                                        var gmail_iphone = click_image_result("gmail_iphone.png")
                                        if (gmail_iphone == "yes") {
                                            sleep(500);
                                            input_keyword(acc_iphone_all);
                                            sleep(500)
                                            laoleng.keys.enter()
                                            sleep(500);
                                            click_image_result("gmail_chi.png")
                                            sleep(5000);
                                        }
                                        sleep(500);

                                        // //判断电话有问题，重新在获取
                                        // var gmail_iphone_beishuyong = click_image_result("gmail_iphone_beishuyong.png")
                                        // if (gmail_iphone_beishuyong == "yes") {
                                        //
                                        //     sleep(500);
                                        //     getsms_activate()
                                        //
                                        //     sleep(500);
                                        //     click_image_result("gmail_iphone_wenbenkuan_h.png")
                                        //     an_delete()
                                        //     sleep(500);
                                        //     input_keyword(acc_iphone_all);
                                        //     sleep(500)
                                        //     laoleng.keys.enter()
                                        //     sleep(10000);
                                        // }
                                        //
                                        // //判断电话有问题，重新在获取2
                                        // var gmail_iphone_beishuyong = click_image_result("gmail_iphone_beishuyong.png")
                                        // if (gmail_iphone_beishuyong == "yes") {
                                        //     sleep(500);
                                        //     getsms_activate()
                                        //
                                        //     sleep(500);
                                        //     click_image_result("gmail_iphone_wenbenkuan_h.png")
                                        //     an_delete()
                                        //     sleep(500);
                                        //     input_keyword(acc_iphone_all);
                                        //     sleep(500)
                                        //     laoleng.keys.enter()
                                        //     sleep(10000);
                                        // }


                                        //输入验证码//  需要获取API接口，电话不行需要获取新电话
                                        var gmail_iphone_yzm = click_image_result("gmail_iphone_yzm.png")
                                        if (gmail_iphone_yzm == "yes") {

                                            //等待验证码
                                            // var gmail_iphone_yzm_page = click_image_result("gmail_iphone_yzm_page.png")
                                            // if (gmail_iphone_yzm_page == "yes") {
                                            for (let e = 0; e < 1; e++) {
                                                acc_iphone_yzm = getsms_activate_yzm();
                                                if (acc_iphone_yzm == "no") {
                                                    acc_iphone_yzm = getsms_activate_yzm();
                                                } else {


                                                    sleep(500);
                                                    input_keyword(acc_iphone_yzm);
                                                    sleep(500)
                                                    laoleng.keys.enter()
                                                    sleep(5000);

                                                    getsms_activate_huichuan2()//回传
                                                    sleep(500);

                                                    //情报确认
                                                    var gmail_iphone_liyongtiaokuan = click_image_result("gmail_iphone_qingbaoqueren.png")
                                                    if (gmail_iphone_liyongtiaokuan == "yes") {
                                                        sleep(500);
                                                        click_image_result("gmail_chi.png")
                                                        sleep(5000);
                                                    }

                                                    //条款
                                                    var gmail_iphone_liyongtiaokuan = click_image_result("gmail_iphone_liyongtiaokuan.png")
                                                    if (gmail_iphone_liyongtiaokuan == "yes") {
                                                        sleep(500);
                                                        huadong_big()
                                                        huadong_big()
                                                        huadong_big()
                                                        click_image_result("gmail_tongyi.png")
                                                        sleep(4000);
                                                    }

                                                    //确认邮箱
                                                    var gmail_iphone_cof = click_image_result("gmail_iphone_cof.png")
                                                    if (gmail_iphone_cof == "yes") {
                                                        sleep(500);
                                                        huadong_big()
                                                        huadong_big()
                                                        sleep(1000)
                                                        click_image_result("gmail_add.png")
                                                        sleep(5000);
                                                        click_image_result("gmail_chi.png")
                                                        sleep(3000);
                                                        huadong_big()
                                                        huadong_big()
                                                        huadong_big()
                                                        click_image_result("gmail_tongyi.png")
                                                        sleep(4000);
                                                        click_image_result("gmail_login.png")
                                                        sleep(4000);
                                                    }

                                                    //关闭gmail app
                                                    sleep(200)
                                                    closeapp("com.google.Gmail")
                                                    logd("关闭app 等待5秒");
                                                    sleep(2000)

                                                    //打开gmail
                                                    var result = appLaunch("com.google.Gmail", "1");
                                                    logd("打开app 等待5秒");
                                                    sleep(2000);

                                                    var gmail_iphone_login = click_image_result("gmail_iphone_login.png")
                                                    if (gmail_iphone_login == "yes") {
                                                        sleep(1000);
                                                        click_image_result("gmail_settings_wangle2.png")
                                                        sleep(500);
                                                        clickPoint(310, 610)
                                                        sleep(500);
                                                        clickPoint(310, 610)
                                                        sleep(500);
                                                        clickPoint(310, 610)
                                                        sleep(500);
                                                        clickPoint(310, 610)
                                                        sleep(500);
                                                        clickPoint(310, 610)
                                                        sleep(500);
                                                        clickPoint(310, 610)
                                                        sleep(1000);
                                                    }


                                                    //点击设置
                                                    sleep(2000);
                                                    var gmail_iphone_shezhi_dian = click_image_result("gmail_iphone_shezhi_dian.png")
                                                    if (gmail_iphone_shezhi_dian == "yes") {
                                                        clickPoint(310, 610)
                                                        sleep(500);
                                                        clickPoint(646, 1248)
                                                        sleep(500);
                                                        clickPoint(310, 610)
                                                        sleep(200);
                                                        click_image_result("gmail_settings_wangle2.png")
                                                        sleep(4000);
                                                        click_image_result("gmail_settings_chadiao.png")
                                                        sleep(4000);
                                                    }

                                                    ////访问邮箱


                                                    //条款
                                                    var gmail_iphone_liyongtiaokuan = click_image_result("gmail_iphone_liyongtiaokuan.png")
                                                    if (gmail_iphone_liyongtiaokuan == "yes") {
                                                        sleep(500);
                                                        huadong_big()
                                                        huadong_big()
                                                        huadong_big()
                                                        click_image_result("gmail_tongyi.png")
                                                        sleep(3000);
                                                    }

                                                    //这里返回首页需要
                                                    var gmail_login = click_image_result("gmail_login.png")
                                                    if (gmail_login == "yes") {
                                                        sleep(1000);
                                                    }
                                                    var gmail_settings_wangle2 = click_image_result("gmail_settings_wangle2.png")
                                                    if (gmail_settings_wangle2 == "yes") {
                                                        sleep(1000);
                                                    }

                                                    //首次设置邮箱
                                                    var gmail_settings = click_image_result("gmail_settings.png")
                                                    if (gmail_settings == "yes") {


                                                        sleep(500);
                                                        click_image_result("gmail_chi2.png")
                                                        sleep(500);
                                                        click_image_result("gmail_settings2.png")
                                                        sleep(500);
                                                        click_image_result("gmail_wangle.png")
                                                        sleep(5000);
                                                        click_image_result("gmail_email_ok.png")
                                                        sleep(1000);
                                                    }

                                                    //叉掉
                                                    var gmail_settings_chadiao = click_image_result("gmail_settings_chadiao.png")
                                                    if (gmail_settings_chadiao == "yes") {
                                                        sleep(500);
                                                    }
                                                    //
                                                    //设置安全认证和辅助邮箱
                                                    var gmail_rg_ok = click_image_result("gmail_rg_ok.png")
                                                    if (gmail_rg_ok == "yes") {
                                                        sleep(200);
                                                        clickPoint(664, 106);
                                                        sleep(500)
                                                        clickPoint(664, 106);

                                                        if (keepScreen()) {
                                                            //全屏识别
                                                            //let ret = ocrText()
                                                            //范围识别
                                                            let ret = ocrText(150, 330, 600, 400)
                                                            if (ret) {
                                                                //遍历结果
                                                                for (let i = 0; i < ret.length; i++) {
                                                                    if (ret[i].includes("@gmail.com")) {
                                                                        acc_email = ret[i];
                                                                        logd(acc_email)
                                                                        sleep(500)

                                                                        //再次回传数据，回传邮箱，辅助邮箱，回传状态
                                                                        getsms_activate_huichuan2()
                                                                        sleep(500)
                                                                    }
                                                                }
                                                            }
                                                        }


                                                        sleep(500);
                                                        click_image_result("gmail_settings_guanli.png")
                                                        sleep(2000);
                                                        click_image_result("gmail_settings_zuijia.png")
                                                        sleep(3000);
                                                        click_image_result("gmail_settings_pass_cik.png")
                                                        sleep(500);
                                                        input_keyword(acc_pass);
                                                        laoleng.keys.enter()
                                                        sleep(3000);

                                                        //输入辅助邮箱
                                                        click_image_result("gmail_settings_fuzhuyoux.png")
                                                        sleep(500);
                                                        input_keyword(acc_email_fuzhu);
                                                        sleep(500);
                                                        click_image_result("gmail_settings_fuzhuyoux_serv.png")
                                                        sleep(3000);
                                                        click_image_result("gmail_settings_x.png")
                                                        sleep(3000);
                                                    }

                                                    ////注册完了关闭重新打开
                                                    // var gmail_settings_guanli = click_image_result("gmail_settings_guanli.png")
                                                    // if (gmail_settings_guanli == "yes") {
                                                    //     //修改amg
                                                    //     new_iphone_new_name();
                                                    //     sleep(500)
                                                    //
                                                    //     //打开乐天app
                                                    //     var result = appLaunch("com.google.Gmail", "1");
                                                    //     logd("打开乐天app 等待5秒");
                                                    //     sleep(2000);
                                                    // }


                                                    // ////设置安全认证跟换电话
                                                    // var gmail_settings_fuzhu = click_image_result("gmail_settings_fuzhu.png")
                                                    // if (gmail_settings_fuzhu == "yes") {
                                                    //     sleep(500);
                                                    //     click_image_result("gmail_settings_guanli.png")
                                                    //     sleep(2000);
                                                    //     click_image_result("gmail_settings_zuijia.png")
                                                    //     sleep(6000);
                                                    //     click_image_result("gmail_settings_pass_cik.png")
                                                    //     sleep(500);
                                                    //     input_keyword(acc_pass);
                                                    //     laoleng.keys.enter()
                                                    //     sleep(6000);
                                                    //
                                                    //     //输入辅助邮箱
                                                    //     click_image_result("gmail_settings_fuzhuyoux.png")
                                                    //     sleep(500);
                                                    //     input_keyword(acc_email_fuzhu);
                                                    //     sleep(500);
                                                    //     click_image_result("gmail_settings_fuzhuyoux_serv.png")
                                                    //     sleep(500);
                                                    //     click_image_result("gmail_settings_x.png")
                                                    //     sleep(1000);
                                                    // }
                                                    //
                                                    // //设置住所
                                                    //
                                                    // var gmail_settings_zhusuo = click_image_result("gmail_settings_zhusuo.png")
                                                    // if (gmail_settings_zhusuo == "yes") {
                                                    //     sleep(5000);
                                                    //     click_image_result("gmail_settings_ditu.png")
                                                    //     sleep(1000);
                                                    //     click_image_result("gmail_settings_baocun.png")
                                                    //     sleep(2000);
                                                    //     huadong()
                                                    //     sleep(5000)
                                                    //     click_image_result("gmail_settings_wangle1.png")
                                                    //     sleep(1000);
                                                    //     click_image_result("gmail_settings_xx.png")
                                                    //     sleep(500)
                                                    //     click_image_result("gmail_settings_fuzhu.png")
                                                    //     sleep(500);
                                                    //
                                                    //
                                                    // }
                                                    //取消号码
                                                    getsms_activate_quxiao()

                                                    //修改amg
                                                    new_iphone_new_name();
                                                    sleep(500)
                                                }
                                            }
                                            // }


                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        //关闭乐天app
        sleep(200)
        closeapp("com.google.Gmail")
        sleep(200)
    }
}

//-------------注册gmail结束---------------------------------------

function generate_year() {
    let start = new Date(1980, 0, 1); // 设置起始日期为1900年1月1日
    let end = new Date(2000, 11, 31); // 设置结束日期为2023年12月31日
    let time = start.getTime() + Math.random() * (end.getTime() - start.getTime());
    let date = new Date(time);
    // 获取随机生成的年月日
    let year = date.getFullYear();
    return year; // 返回格式化的年月日字符串
}

function generate_yue() {
    let start = new Date(1980, 0, 1); // 设置起始日期为1900年1月1日
    let end = new Date(2000, 11, 31); // 设置结束日期为2023年12月31日
    let time = start.getTime() + Math.random() * (end.getTime() - start.getTime());
    let date = new Date(time);
    // 获取随机生成的年月日
    let month = ('0' + (date.getMonth() + 1)).slice(-2); // 月份需要加1因为从0开始，slice保证两位数
    return month; // 返回格式化的年月日字符串
}


function generate_day() {
    let start = new Date(1980, 0, 1); // 设置起始日期为1900年1月1日
    let end = new Date(2000, 11, 30); // 设置结束日期为2023年12月31日
    let time = start.getTime() + Math.random() * (end.getTime() - start.getTime());
    let date = new Date(time);
    // 获取随机生成的年月日
    let day = ('0' + date.getDate()).slice(-2); // slice保证两位数
    return day; // 返回格式化的年月日字符串
}

function randomsex() {
    const randomNumber = Math.random(); // 生成一个[0, 1)之间的随机数
    return randomNumber < 0.5 ? 'male' : 'female'; // 根据随机数决定性别
}


function generatePassword(length) {
    let charset = '1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!@#$%^&*()_-{}[]<>?+|'; // 包含了大小写字母和特殊符号
    let retVal = Array(length).fill('').map(_ => charset.charAt(Math.floor(Math.random() * charset.length)));

    return generatePassworda_z(1) + retVal.join('') + generatePasswordnumber(1) + generatePassworda_zd(1);
}

function generatePasswordnumber(length) {
    let charset = '1234567890'; // 包含了大小写字母和特殊符号
    let retVal = Array(length).fill('').map(_ => charset.charAt(Math.floor(Math.random() * charset.length)));
    return retVal.join('');
}

function generatePassworda_z(length) {
    let charset = 'abcdefghijklmnopqrstuvwxyz'; // 包含了大小写字母和特殊符号
    let retVal = Array(length).fill('').map(_ => charset.charAt(Math.floor(Math.random() * charset.length)));
    return retVal.join('');
}

function generatePassworda_zd(length) {
    let charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; // 包含了大小写字母和特殊符号
    let retVal = Array(length).fill('').map(_ => charset.charAt(Math.floor(Math.random() * charset.length)));
    return retVal.join('');
}


//重新获取号码
function laolen_gettxt_email() {
    //记得先截图
    if (keepScreen()) {
        console.time("1")
        //全屏识别
        //let ret = ocrNormal()
        //范围识别
        let ret = ocrNormal(94, 664, 688, 766)
        if (ret) {
            for (let i = 0; i < ret.length; i++) {
                let strgmail = ret[i].label;
                acc_email = strgmail;
                logd(strgmail)
                return acc_email
            }
        }
    }

}


//qoo10_register
function qoo10_register() {
    if (findNode(label("Qoo10会員登録").type("Button"), true)) {
        console.log('点击了左边按钮')
    }

    if (findNode(label("ログイン").type("Button"), true)) {
        console.log('点击了左边按钮')
    }

    return false
    //记得先截图
    if (keepScreen()) {
        console.time("1")
        //全屏识别
        //let ret = ocrNormal()
        //范围识别
        let ret = ocrNormal(94, 664, 688, 766)
        if (ret) {
            for (let i = 0; i < ret.length; i++) {
                let strgmail = ret[i].label;
                acc_email = strgmail;
                logd(strgmail)
                return acc_email
            }
        }
    }

}

//ins_register
function ins_register() {
    // //切换账户
    //new_iphone();
    sleep(500);
    ////home();
    //打开乐天app
    // var result = appLaunch("com.burbn.instagram", "1");
    // logd("打开app 等待2秒");
    // sleep(4000);
    //
    // clickPoint(360, 1150);////点击注册
    // sleep(3000);
    // clickPoint(352, 846);//点击邮箱注册
    // sleep(3000);
    // clickPoint(94, 440);//点击填写邮箱
    // sleep(500);
    // input_keyword("jiantailangshangli@gmail.com"); //jiantailangshangli@gmail.com-----dYU{t^uW6@L0G
    // sleep(500);
    // clickPoint(360, 592);//点击填写邮箱
    // sleep(2000);

    //等待验证码切换到Gmail邮箱
    // var result = appLaunch("com.google.Gmail", "1");
    // logd("打开app 等待2秒");
    // sleep(5000);
    // clickPoint(310, 318);//点击填写邮箱
    // sleep(2000);

    //获取验证码
    //记得先截图
    laoleng.EC.initOcr({"level": "accurate"})
//记得先截图
    let appleVision = {"type": "appleVision", "level": "accurate", "languages": "zh-Hans,en-US"}
    let inited = ocr.initOcr(appleVision)
    logd("初始化结果 -" + inited);
    if (!inited) {
        loge("error : " + ocr.getErrorMsg());
        return;
    }
    i

    for (var ix = 0; ix < 20; ix++) {

        //读取一个bitmap
        let img = image.captureFullScreen();
        if (img == null || img == undefined || img.uuid == null || img.uuid == undefined || img.uuid == "") {
            loge("读取图片失败");
            continue;
        }
        console.time("1")
        logd("start---ocr");
        // 对图片进行识别
        let result = ocr.ocrImage(img, 20 * 1000, {});
        logd(result)
        if (result) {
            logd("ocr结果-》 " + JSON.stringify(result));
            for (var i = 0; i < result.length; i++) {
                var value = result[i];
                logd("文字 : " + value.label + " x: " + value.x + " y: " + value.y + " width: " + value.width + " height: " + value.height);
            }
        } else {
            logw("未识别到结果");
        }

        logd("耗时: " + console.timeEnd(1) + " ms")
        image.recycle(img)
        sleep(1000);
        logd("ix = " + ix)
    }
    //释放所有资源
    ocr.releaseAll();

    exit()


    while (true) {
        sleep(10)
        if (!keepScreen()) {
            continue
        }
        //只填图片名
        if (findImageByColorAll("ins_rg.png")) {
            logd("1:" + JSON.stringify(gPointAll))
            for (let i = 0; i < gPointAll.length; i++) {
                logd(gPointAll[i].x, gPointAll[i].y)
                clickPoint(gPointAll[i].x, gPointAll[i].y)
                sleep(500)
            }

        }
    }
    exit()

    //今はしない
    click_tanchuan()
    logd("点击首页今はしない");
    sleep(200);
    click_tanchuan()
    logd("点击首页今はしない");
    sleep(1000);
    var disp_ads = click_image_result("disp_ads.png")
    if (disp_ads == "yes") {
        sleep(200);
        click_image("guangbi.png")
        sleep(1000);
    }

    // 判断登录成功
    // 搜索产品点到产品页面
    sleep(500);
    var search_1 = click_image_result7("search_1.png")
    if (search_1 == "yes") {


    }
}

//ins_publish
function ins_publish() {
    //记得先截图
    if (keepScreen()) {
        console.time("1")
        //全屏识别
        //let ret = ocrNormal()
        //范围识别
        let ret = ocrNormal(94, 664, 688, 766)
        if (ret) {
            for (let i = 0; i < ret.length; i++) {
                let strgmail = ret[i].label;
                acc_email = strgmail;
                logd(strgmail)
                return acc_email
            }
        }
    }

}

//youtable_register
function youtable_register() {
    //记得先截图
    if (keepScreen()) {
        console.time("1")
        //全屏识别
        //let ret = ocrNormal()
        //范围识别
        let ret = ocrNormal(94, 664, 688, 766)
        if (ret) {
            for (let i = 0; i < ret.length; i++) {
                let strgmail = ret[i].label;
                acc_email = strgmail;
                logd(strgmail)
                return acc_email
            }
        }
    }

}

//youtable_publish
function youtable_publish() {
    //记得先截图
    if (keepScreen()) {
        console.time("1")
        //全屏识别
        //let ret = ocrNormal()
        //范围识别
        let ret = ocrNormal(94, 664, 688, 766)
        if (ret) {
            for (let i = 0; i < ret.length; i++) {
                let strgmail = ret[i].label;
                acc_email = strgmail;
                logd(strgmail)
                return acc_email
            }
        }
    }
}

//lm8_register
function lm8_register() {
    //记得先截图
    if (keepScreen()) {
        console.time("1")
        //全屏识别
        //let ret = ocrNormal()
        //范围识别
        let ret = ocrNormal(94, 664, 688, 766)
        if (ret) {
            for (let i = 0; i < ret.length; i++) {
                let strgmail = ret[i].label;
                acc_email = strgmail;
                logd(strgmail)
                return acc_email
            }
        }
    }
}


//lm8_publish
function lm8_publish() {
    //记得先截图
    if (keepScreen()) {
        console.time("1")
        //全屏识别
        //let ret = ocrNormal()
        //范围识别
        let ret = ocrNormal(94, 664, 688, 766)
        if (ret) {
            for (let i = 0; i < ret.length; i++) {
                let strgmail = ret[i].label;
                acc_email = strgmail;
                logd(strgmail)
                return acc_email
            }
        }
    }
}

//tk_register
function tk_register() {
    //记得先截图
    if (keepScreen()) {
        console.time("1")
        //全屏识别
        //let ret = ocrNormal()
        //范围识别
        let ret = ocrNormal(94, 664, 688, 766)
        if (ret) {
            for (let i = 0; i < ret.length; i++) {
                let strgmail = ret[i].label;
                acc_email = strgmail;
                logd(strgmail)
                return acc_email
            }
        }
    }
}


//tk_publish
function tk_publish() {
    //记得先截图
    if (keepScreen()) {
        console.time("1")
        //全屏识别
        //let ret = ocrNormal()
        //范围识别
        let ret = ocrNormal(94, 664, 688, 766)
        if (ret) {
            for (let i = 0; i < ret.length; i++) {
                let strgmail = ret[i].label;
                acc_email = strgmail;
                logd(strgmail)
                return acc_email
            }
        }
    }
}

//x_register
function x_register() {
    //记得先截图
    if (keepScreen()) {
        console.time("1")
        //全屏识别
        //let ret = ocrNormal()
        //范围识别
        let ret = ocrNormal(94, 664, 688, 766)
        if (ret) {
            for (let i = 0; i < ret.length; i++) {
                let strgmail = ret[i].label;
                acc_email = strgmail;
                logd(strgmail)
                return acc_email
            }
        }
    }
}


//x_publish
function x_publish() {
    //记得先截图
    if (keepScreen()) {
        console.time("1")
        //全屏识别
        //let ret = ocrNormal()
        //范围识别
        let ret = ocrNormal(94, 664, 688, 766)
        if (ret) {
            for (let i = 0; i < ret.length; i++) {
                let strgmail = ret[i].label;
                acc_email = strgmail;
                logd(strgmail)
                return acc_email
            }
        }
    }
}


//amazon_publish
function amazon_register() {
    //记得先截图
    if (keepScreen()) {
        console.time("1")
        //全屏识别
        //let ret = ocrNormal()
        //范围识别
        let ret = ocrNormal(94, 664, 688, 766)
        if (ret) {
            for (let i = 0; i < ret.length; i++) {
                let strgmail = ret[i].label;
                acc_email = strgmail;
                logd(strgmail)
                return acc_email
            }
        }
    }
}

//root_register
function root_register() {
    //记得先截图
    if (keepScreen()) {
        console.time("1")
        //全屏识别
        //let ret = ocrNormal()
        //范围识别
        let ret = ocrNormal(94, 664, 688, 766)
        if (ret) {
            for (let i = 0; i < ret.length; i++) {
                let strgmail = ret[i].label;
                acc_email = strgmail;
                logd(strgmail)
                return acc_email
            }
        }
    }
}

//root_publish
function root_publish() {
    //记得先截图
    if (keepScreen()) {
        console.time("1")
        //全屏识别
        //let ret = ocrNormal()
        //范围识别
        let ret = ocrNormal(94, 664, 688, 766)
        if (ret) {
            for (let i = 0; i < ret.length; i++) {
                let strgmail = ret[i].label;
                acc_email = strgmail;
                logd(strgmail)
                return acc_email
            }
        }
    }
}
